├── LICENSE ├── README.md ├── part1 ├── README.md ├── analogRead-free-runnig-v1r0.ino ├── analogRead-free-runnig-v1r1.ino ├── arduino-carb-sync-part1-001.PNG ├── example-4-sensors │ ├── README.md │ └── analogRead-free-runnig-v1r2.ino └── serial-plot-part1.PNG ├── part2 ├── README.md ├── arduino-analogread-freerunning-part2.v0.r2.ino └── serial-plot-part2.PNG ├── part3 ├── README.md ├── arduino-carb-sync-part3-001.PNG ├── arduino-carb-sync-part3-002.PNG ├── arduino-nextion-serial-communication.HMI ├── arduino-nextion-serial-communication.ino └── arduino-nextion-serial-communication.tft ├── part4 ├── Nextion files │ ├── arduino-carb-sync-nextion.HMI │ ├── arduino-carb-sync-nextion.tft │ └── courier_16.zi ├── README.md ├── arduino-carb-sync-nextion.ino ├── arduino-carb-sync-part4-001.PNG └── arduino-carb-sync-part4-002.PNG ├── part5 ├── Nextion files │ ├── arduino-carb-sync-nextion-part5.HMI │ ├── arduino-carb-sync-nextion-part5.tft │ └── courier_16.zi ├── README.md ├── arduino-analogread-freerunning-part5.v0.r0.ino ├── arduino-carb-sync-part5-001.PNG └── arduino-carb-sync-part5-002.PNG ├── part6 ├── Nextion files │ ├── arduino-carb-sync-with-battery.HMI │ ├── arduino-carb-sync-with-battery.tft │ └── courier_16.zi ├── README.md ├── arduino-carb-sync-part6-001.PNG └── arduino-carb-sync-part6-002.PNG └── pressure-intake-duct.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 yz88 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # arduino-digital-carb-sync 2 | 3 | Motorcycle carburetor synchronization based on Arduino Uno, Nextion Display and analog pressure sensors. 4 | 5 | ## the theory 6 | 7 | The part of the signal that ramps downward is the intake stroke of the engine. The part of the signal that ramps upward is the compression, power and exhaust stroke combined. 8 | 9 | ![Pressure in the intake duct.](https://github.com/yz88/arduino-digital-carb-sync/blob/master/pressure-intake-duct.png) 10 | 11 | The entire vacuum signal from the intake stroke alone is analyzed for synchronization by finding the min peak of the vacuum. If the min peaks of both cylinders are on the same level, the carburetors are syncronized. 12 | 13 | ## bill of material 14 | 15 | * Arduino Uno 16 | * Nextion Display (NX3224T024_011R (R: Resistive touchscreen) ) 17 | * Analog Pressure Sensors (MPX4115AP) 18 | 19 | ## step by step development 20 | 21 | [Part 1 - Arduino freerunning analog read (first steps)](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part1/) 22 | 23 | [Part 2 - Arduino freerunning analog read and smoothing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part2/) 24 | 25 | [Part 3 - Arduino and Nextion Display (first steps)](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part3/) 26 | 27 | [Part 4 - Arduino and Nextion Display Waveform](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part4/) 28 | 29 | [Part 5 - Arduino and Nextion Display Progressbar (final version)](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part5/) 30 | 31 | [Part 6 - Special version with battery voltage measurement](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part6/) 32 | -------------------------------------------------------------------------------- /part1/README.md: -------------------------------------------------------------------------------- 1 | # part 1 - arduino-free-running-analog-read 2 | 3 | Part 1 covers fast reading of analog values. The values are raw values without smoothing. 4 | 5 | ## bill of material 6 | 7 | * Arduino Uno 8 | * Analog Pressure Sensors (MPX4115AP) 9 | * Capacitors 1µF and 100nF 10 | 11 | ## schematic 12 | 13 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part1/arduino-carb-sync-part1-001.PNG) 14 | 15 | ## serial plot 16 | 17 | The following graph shows the measurement curves of the two pressure sensors. The blue line shows the first pressure sensor (right cylinder), the red line the second (left cylinder). 18 | 19 | ![Serial Plot](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part1/serial-plot-part1.PNG) 20 | -------------------------------------------------------------------------------- /part1/analogRead-free-runnig-v1r0.ino: -------------------------------------------------------------------------------- 1 | // Testing interrupt-based analog reading 2 | // ATMega328p 3 | 4 | // Note, many macro values are defined in and 5 | // , which are included automatically by 6 | // the Arduino interface 7 | 8 | 9 | volatile int readFlag; // High when a value is ready to be read 10 | volatile int analogVal_ADC4; // Value to store analog result from ADC4 11 | volatile int analogVal_ADC5; // Value to store analog result from ADC5 12 | unsigned long time; 13 | 14 | #define sensor1 4 // left pressure sensor 15 | #define sensor2 5 // right pressure sensor 16 | 17 | #ifndef cbi 18 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 19 | #endif 20 | #ifndef sbi 21 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 22 | #endif 23 | 24 | 25 | void setup() { 26 | Serial.begin(115200); 27 | Serial.println("Setup"); 28 | Serial.println(ADMUX); 29 | 30 | pinMode(sensor1, INPUT); 31 | pinMode(sensor2, INPUT); 32 | 33 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 34 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 35 | cbi(ADMUX, ADLAR); 36 | Serial.println("Set ADLAR in ADMUX"); 37 | Serial.println(ADMUX); 38 | 39 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 40 | // proper source (01) 41 | sbi(ADMUX, REFS0); 42 | cbi(ADMUX, REFS1); 43 | Serial.println("Set REFS1..0 in ADMUX"); 44 | Serial.println(ADMUX); 45 | 46 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) 47 | cbi(ADMUX, MUX3); 48 | sbi(ADMUX, MUX2); 49 | cbi(ADMUX, MUX1); 50 | cbi(ADMUX, MUX0); 51 | Serial.println("Set MUX3..0 in ADMUX"); 52 | Serial.println(ADMUX); 53 | 54 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 55 | sbi(ADCSRA, ADEN); // enable ADC 56 | Serial.println("Set ADEN in ADCSRA"); 57 | Serial.println(ADCSRA); 58 | 59 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 60 | sbi(ADCSRA, ADATE); // enable auto trigger 61 | Serial.println("Set ADATE in ADCSRA"); 62 | Serial.println(ADCSRA); 63 | 64 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 65 | // This means that as soon as an ADC has finished, the next will be 66 | // immediately started. 67 | cbi(ADCSRB, ADTS2); 68 | cbi(ADCSRB, ADTS1); 69 | cbi(ADCSRB, ADTS0); 70 | Serial.println("Set ADTS2..0 in ADCSRB"); 71 | Serial.println(ADCSRA); 72 | 73 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 74 | // Above 200KHz 10-bit results are not reliable. 75 | sbi(ADCSRA, ADPS2); 76 | sbi(ADCSRA, ADPS1); 77 | sbi(ADCSRA, ADPS0); 78 | Serial.println("Set ADPS2..0 in ADCSRA"); 79 | Serial.println(ADCSRA); 80 | 81 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 82 | // Without this, the internal interrupt will not trigger. 83 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 84 | Serial.println("Set ADIE in ADCSRA"); 85 | Serial.println(ADCSRA); 86 | 87 | // Enable global interrupts 88 | // AVR macro included in , which the Arduino IDE 89 | // supplies by default. 90 | sei(); 91 | 92 | // Kick off the first ADC 93 | readFlag = 0; 94 | 95 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 96 | sbi(ADCSRA, ADSC); // start ADC measurements 97 | Serial.println("Set ADSC in ADCSRA"); 98 | Serial.println(ADCSRA); 99 | } 100 | 101 | 102 | void loop(){ 103 | // Check to see if the value has been updated 104 | if (readFlag == 1){ 105 | // Perform whatever updating needed 106 | //Serial.print("Time: "); 107 | //time = millis(); 108 | //Serial.print(time); //prints time since program started 109 | //Serial.print(" : Value ADC4 | ADC5: "); 110 | Serial.print(analogVal_ADC4); 111 | Serial.print(" "); 112 | Serial.println (analogVal_ADC5); 113 | readFlag = 0; 114 | } 115 | // Whatever else you would normally have running in loop(). 116 | } 117 | 118 | 119 | // Interrupt service routine for the ADC completion 120 | ISR(ADC_vect){ 121 | // Done reading 122 | readFlag = 1; 123 | 124 | // toggling analog input pin between 4 (A4) and 5 (A5) 125 | if (ADMUX == 0x44) { 126 | // Must read low first 127 | analogVal_ADC4 = ADCL | (ADCH << 8); 128 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) to read from ACD5 (0101) 129 | sbi(ADMUX, MUX0); 130 | } 131 | else if (ADMUX == 0x45){ 132 | // Must read low first 133 | analogVal_ADC5 = ADCL | (ADCH << 8); 134 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC5 (0101) to read from ACD5 (0100) 135 | cbi(ADMUX, MUX0); 136 | } 137 | 138 | // Not needed because free-running mode is enabled. 139 | // Set ADSC in ADCSRA (0x7A) to start another ADC conversion 140 | // sbi(ADCSRA, ADSC); // start ADC measurements 141 | } 142 | -------------------------------------------------------------------------------- /part1/analogRead-free-runnig-v1r1.ino: -------------------------------------------------------------------------------- 1 | // Testing interrupt-based analog reading 2 | // ATMega328p 3 | 4 | // Note, many macro values are defined in and 5 | // , which are included automatically by 6 | // the Arduino interface 7 | 8 | 9 | volatile int readFlag; // High when a value is ready to be read 10 | volatile int analogVal_ADC4; // Value to store analog result from ADC4 11 | volatile int analogVal_ADC5; // Value to store analog result from ADC5 12 | unsigned long time; 13 | 14 | #define sensor1 4 // left pressure sensor 15 | #define sensor2 5 // right pressure sensor 16 | 17 | int PressureLeft = 1023; 18 | int previousPressureLeft = 1023; 19 | 20 | int PressureRight = 1023; 21 | int previousPressureRight = 1023; 22 | 23 | int DifferenceLeft = 0; 24 | int DifferenceRight = 0; 25 | 26 | #ifndef cbi 27 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 28 | #endif 29 | #ifndef sbi 30 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 31 | #endif 32 | 33 | 34 | void setup() { 35 | Serial.begin(115200); 36 | 37 | pinMode(sensor1, INPUT); 38 | pinMode(sensor2, INPUT); 39 | 40 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 41 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 42 | cbi(ADMUX, ADLAR); 43 | 44 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 45 | // proper source (01) 46 | sbi(ADMUX, REFS0); 47 | cbi(ADMUX, REFS1); 48 | 49 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) 50 | cbi(ADMUX, MUX3); 51 | sbi(ADMUX, MUX2); 52 | cbi(ADMUX, MUX1); 53 | cbi(ADMUX, MUX0); 54 | 55 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 56 | sbi(ADCSRA, ADEN); // enable ADC 57 | 58 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 59 | sbi(ADCSRA, ADATE); // enable auto trigger 60 | 61 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 62 | // This means that as soon as an ADC has finished, the next will be 63 | // immediately started. 64 | cbi(ADCSRB, ADTS2); 65 | cbi(ADCSRB, ADTS1); 66 | cbi(ADCSRB, ADTS0); 67 | 68 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 69 | // Above 200KHz 10-bit results are not reliable. 70 | sbi(ADCSRA, ADPS2); 71 | sbi(ADCSRA, ADPS1); 72 | sbi(ADCSRA, ADPS0); 73 | 74 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 75 | // Without this, the internal interrupt will not trigger. 76 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 77 | 78 | // Enable global interrupts 79 | // AVR macro included in , which the Arduino IDE 80 | // supplies by default. 81 | sei(); 82 | 83 | // Kick off the first ADC 84 | readFlag = 0; 85 | 86 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 87 | sbi(ADCSRA, ADSC); // start ADC measurements 88 | 89 | delay(100); 90 | 91 | // calibrate sensors to the same level 92 | // get some values and find the lowest value 93 | for (int i=0; i <= 255; i++){ 94 | PressureLeft = analogVal_ADC4; 95 | PressureRight = analogVal_ADC5; 96 | if (PressureLeft < previousPressureLeft) { 97 | previousPressureLeft = PressureLeft; // store the lowest value 98 | } 99 | if (PressureRight < previousPressureRight) { 100 | previousPressureRight = PressureRight; // store the lowest value 101 | } 102 | } 103 | 104 | // compare the lowest values of ADC4 and ADC5, then calculating the difference 105 | if (previousPressureLeft > previousPressureRight){ 106 | DifferenceRight = previousPressureLeft - previousPressureRight; 107 | } else { 108 | DifferenceLeft = previousPressureRight - previousPressureLeft; 109 | } 110 | } 111 | 112 | 113 | void loop(){ 114 | // Check to see if the value has been updated 115 | if (readFlag == 1){ 116 | PressureLeft = analogVal_ADC4 + DifferenceLeft; 117 | PressureRight = analogVal_ADC5 + DifferenceRight; 118 | Serial.print(PressureLeft); 119 | Serial.print(" "); 120 | Serial.println (PressureRight); 121 | readFlag = 0; 122 | } 123 | // Whatever else you would normally have running in loop(). 124 | } 125 | 126 | 127 | // Interrupt service routine for the ADC completion 128 | ISR(ADC_vect){ 129 | // Done reading 130 | readFlag = 1; 131 | 132 | // toggling analog input pin between 4 (A4) and 5 (A5) 133 | if (ADMUX == 0x44) { 134 | // Must read low first 135 | analogVal_ADC4 = ADCL | (ADCH << 8); 136 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) to read from ACD5 (0101) 137 | sbi(ADMUX, MUX0); 138 | } else if (ADMUX == 0x45){ 139 | // Must read low first 140 | analogVal_ADC5 = ADCL | (ADCH << 8); 141 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC5 (0101) to read from ACD5 (0100) 142 | cbi(ADMUX, MUX0); 143 | } 144 | 145 | // Not needed because free-running mode is enabled. 146 | // Set ADSC in ADCSRA (0x7A) to start another ADC conversion 147 | // sbi(ADCSRA, ADSC); // start ADC measurements 148 | } 149 | -------------------------------------------------------------------------------- /part1/arduino-carb-sync-part1-001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part1/arduino-carb-sync-part1-001.PNG -------------------------------------------------------------------------------- /part1/example-4-sensors/README.md: -------------------------------------------------------------------------------- 1 | # part 1 - arduino-free-running-analog-read (extended) 2 | 3 | With this extended code of part 1 the Arduino Uno reads 4 sensors (analog pin ADC0 to ADC3) -------------------------------------------------------------------------------- /part1/example-4-sensors/analogRead-free-runnig-v1r2.ino: -------------------------------------------------------------------------------- 1 | // Testing interrupt-based analog reading 2 | // ATMega328p 3 | 4 | // Note, many macro values are defined in and 5 | // , which are included automatically by 6 | // the Arduino interface 7 | 8 | volatile int readFlag; // High when a value is ready to be read 9 | volatile int analogVal_ADC0; // Value to store analog result from ADC0 10 | volatile int analogVal_ADC1; // Value to store analog result from ADC1 11 | volatile int analogVal_ADC2; // Value to store analog result from ADC2 12 | volatile int analogVal_ADC3; // Value to store analog result from ADC3 13 | unsigned long time; 14 | 15 | #define sensor0 0 // pressure sensor ADC0 16 | #define sensor1 1 // pressure sensor ADC1 17 | #define sensor2 2 // pressure sensor ADC2 18 | #define sensor3 3 // pressure sensor ADC3 19 | 20 | int PressureSensor0 = 1023; 21 | int LowestValueSensor0 = 1023; 22 | int DifferenceSensor0 = 0; 23 | 24 | int PressureSensor1 = 1023; 25 | int LowestValueSensor1 = 1023; 26 | int DifferenceSensor1 = 0; 27 | 28 | int PressureSensor2 = 1023; 29 | int LowestValueSensor2 = 1023; 30 | int DifferenceSensor2 = 0; 31 | 32 | int PressureSensor3 = 1023; 33 | int LowestValueSensor3 = 1023; 34 | int DifferenceSensor3 = 0; 35 | 36 | int LowestValueAllSensors = 1023; 37 | 38 | /** 39 | ** Clear BIT function 40 | * this function is used to clear a BIT in a register 41 | * -> set BIT to logic '0' 42 | */ 43 | #ifndef cbi 44 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 45 | #endif 46 | 47 | /** 48 | ** Set BIT function 49 | * this function is used t set a BIT in a register 50 | * -> set BIT to logic '1' 51 | */ 52 | #ifndef sbi 53 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 54 | #endif 55 | 56 | void setup() 57 | { 58 | Serial.begin(115200); 59 | 60 | pinMode(sensor0, INPUT); 61 | pinMode(sensor1, INPUT); 62 | pinMode(sensor2, INPUT); 63 | pinMode(sensor3, INPUT); 64 | 65 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 66 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 67 | cbi(ADMUX, ADLAR); 68 | 69 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 70 | // proper source (01) 71 | sbi(ADMUX, REFS0); 72 | cbi(ADMUX, REFS1); 73 | 74 | /** 75 | ** ADMUX - ADC Mulitplexer Selection Register 76 | * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 77 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 78 | * (0x7C) | REFS1 | REFS0 | ADLAR | MUX4 | MUX3 | MUX2 | MUX1 | MUX0 | 79 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 80 | * Read/Write | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | 81 | * Inital Value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 82 | * 83 | ** Changing Channel or Reference Selection 84 | * The Analog Channel Selection bits (MUX) in the ADC Multiplexer Selection Register (ADMUX.MUX[3:0]) 85 | * determine the analog input to be read from. 86 | * 87 | * +------+------+------+------+------------+ 88 | * | MUX3 | MUX2 | MUX1 | MUX0 | Analog PIN | 89 | * +------+------+------+------+------------+ 90 | * | 0 | 0 | 0 | 0 | ADC0 | 91 | * | 0 | 0 | 0 | 1 | ADC1 | 92 | * | 0 | 0 | 1 | 0 | ADC2 | 93 | * | 0 | 0 | 1 | 1 | ADC3 | 94 | * | 0 | 1 | 0 | 0 | ADC4 | 95 | * | 0 | 1 | 0 | 1 | ADC5 | 96 | * | 0 | 1 | 1 | 0 | ADC6 | 97 | * +------+------+------+------+------------+ 98 | */ 99 | 100 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC0 (0000) 101 | cbi(ADMUX, MUX3); 102 | cbi(ADMUX, MUX2); 103 | cbi(ADMUX, MUX1); 104 | cbi(ADMUX, MUX0); 105 | 106 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 107 | sbi(ADCSRA, ADEN); // enable ADC 108 | 109 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 110 | sbi(ADCSRA, ADATE); // enable auto trigger 111 | 112 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 113 | // This means that as soon as an ADC has finished, the next will be 114 | // immediately started. 115 | cbi(ADCSRB, ADTS2); 116 | cbi(ADCSRB, ADTS1); 117 | cbi(ADCSRB, ADTS0); 118 | 119 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 120 | // Above 200KHz 10-bit results are not reliable. 121 | sbi(ADCSRA, ADPS2); 122 | sbi(ADCSRA, ADPS1); 123 | sbi(ADCSRA, ADPS0); 124 | 125 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 126 | // Without this, the internal interrupt will not trigger. 127 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 128 | 129 | // Enable global interrupts 130 | // AVR macro included in , which the Arduino IDE 131 | // supplies by default. 132 | sei(); 133 | 134 | // Kick off the first ADC 135 | readFlag = 0; 136 | 137 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 138 | sbi(ADCSRA, ADSC); // start ADC measurements 139 | 140 | delay(100); 141 | 142 | // calibrate sensors to the same level 143 | // get some values and find the lowest value 144 | for (int i = 0; i <= 255; i++) 145 | { 146 | PressureSensor0 = analogVal_ADC0; 147 | PressureSensor1 = analogVal_ADC1; 148 | PressureSensor2 = analogVal_ADC2; 149 | PressureSensor3 = analogVal_ADC3; 150 | if (PressureSensor0 < LowestValueSensor0) 151 | { 152 | LowestValueSensor0 = PressureSensor0; // store the lowest value 153 | } 154 | if (PressureSensor1 < LowestValueSensor1) 155 | { 156 | LowestValueSensor1 = PressureSensor1; // store the lowest value 157 | } 158 | if (PressureSensor2 < LowestValueSensor2) 159 | { 160 | LowestValueSensor2 = PressureSensor2; // store the lowest value 161 | } 162 | if (PressureSensor3 < LowestValueSensor3) 163 | { 164 | LowestValueSensor3 = PressureSensor3; // store the lowest value 165 | } 166 | } 167 | 168 | // compare the lowest values of ADC0, ADC1, ADC2 and ADC3, then calculating the difference 169 | 170 | if (LowestValueSensor0 < LowestValueAllSensors) 171 | { 172 | LowestValueAllSensors = LowestValueSensor0 173 | } 174 | if (LowestValueSensor1 < LowestValueAllSensors) 175 | { 176 | LowestValueAllSensors = LowestValueSensor1 177 | } 178 | if (LowestValueSensor2 < LowestValueAllSensors) 179 | { 180 | LowestValueAllSensors = LowestValueSensor2 181 | } 182 | if (LowestValueSensor3 < LowestValueAllSensors) 183 | { 184 | LowestValueAllSensors = LowestValueSensor3 185 | } 186 | 187 | // Difference of each sensor is positive or in one case zero 188 | DifferenceSensor0 = LowestValueSensor0 - LowestValueAllSensors; 189 | DifferenceSensor1 = LowestValueSensor1 - LowestValueAllSensors; 190 | DifferenceSensor2 = LowestValueSensor2 - LowestValueAllSensors; 191 | DifferenceSensor3 = LowestValueSensor3 - LowestValueAllSensors; 192 | } 193 | 194 | void loop() 195 | { 196 | // Check to see if the value has been updated 197 | if (readFlag == 1) 198 | { 199 | PressureSensor0 = analogVal_ADC0 - DifferenceSensor0; 200 | PressureSensor1 = analogVal_ADC1 - DifferenceSensor1; 201 | PressureSensor2 = analogVal_ADC2 - DifferenceSensor2; 202 | PressureSensor3 = analogVal_ADC3 - DifferenceSensor3; 203 | Serial.print(PressureSensor0); 204 | Serial.print(" "); 205 | Serial.print(PressureSensor1); 206 | Serial.print(" "); 207 | Serial.print(PressureSensor2); 208 | Serial.print(" "); 209 | Serial.println(PressureSensor3); 210 | readFlag = 0; 211 | } 212 | // Whatever else you would normally have running in loop(). 213 | } 214 | 215 | // Interrupt service routine for the ADC completion 216 | ISR(ADC_vect) 217 | { 218 | // Done reading 219 | readFlag = 1; 220 | 221 | // toggling analog input pins 222 | if (ADMUX == 0x40) 223 | { 224 | /** 225 | ** ADMUX - ADC Mulitplexer Selection Register 226 | * actually ADMUX is set to read from ADC0 (0000) 227 | * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 228 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 229 | * (0x7C) | REFS1 | REFS0 | ADLAR | MUX4 | MUX3 | MUX2 | MUX1 | MUX0 | 230 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 231 | * Value | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 232 | */ 233 | // Must read low first 234 | analogVal_ADC0 = ADCL | (ADCH << 8); 235 | /** 236 | ** Set MUX3..0 in ADMUX (0x7C) to read from ACD1 (0001) 237 | * do this by setting MUX0 to '1' 238 | */ 239 | sbi(ADMUX, MUX0); 240 | } 241 | else if (ADMUX == 0x41) 242 | { 243 | /** 244 | ** ADMUX - ADC Mulitplexer Selection Register 245 | * actually ADMUX is set to read from ADC1 (0001) 246 | * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 247 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 248 | * (0x7C) | REFS1 | REFS0 | ADLAR | MUX4 | MUX3 | MUX2 | MUX1 | MUX0 | 249 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 250 | * Value | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 251 | */ 252 | // Must read low first 253 | analogVal_ADC1 = ADCL | (ADCH << 8); 254 | /** 255 | ** Set MUX3..0 in ADMUX (0x7C) to read from ACD2 (0010) 256 | * do this by setting MUX0 to '0' and MUX1 to '1' 257 | */ 258 | cbi(ADMUX, MUX0); 259 | sbi(ADMUX, MUX1); 260 | } 261 | else if (ADMUX == 0x42) 262 | { 263 | /** 264 | ** ADMUX - ADC Mulitplexer Selection Register 265 | * actually ADMUX is set to read from ADC2 (0010) 266 | * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 267 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 268 | * (0x7C) | REFS1 | REFS0 | ADLAR | MUX4 | MUX3 | MUX2 | MUX1 | MUX0 | 269 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 270 | * Value | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 271 | */ 272 | // Must read low first 273 | analogVal_ADC2 = ADCL | (ADCH << 8); 274 | /** 275 | ** Set MUX3..0 in ADMUX (0x7C) to read from ACD3 (0011) 276 | * do this by setting MUX0 to '1' 277 | */ 278 | sbi(ADMUX, MUX0); 279 | } 280 | else if (ADMUX == 0x43) 281 | { 282 | /** 283 | ** ADMUX - ADC Mulitplexer Selection Register 284 | * actually ADMUX is set to read from ADC3 (0011) 285 | * Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 286 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 287 | * (0x7C) | REFS1 | REFS0 | ADLAR | MUX4 | MUX3 | MUX2 | MUX1 | MUX0 | 288 | * +-------+-------+-------+-------+-------+-------+-------+-------+ 289 | * Value | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 290 | */ 291 | // Must read low first 292 | analogVal_ADC2 = ADCL | (ADCH << 8); 293 | /** 294 | ** Set MUX3..0 in ADMUX (0x7C) to read from ACD0 (0000) 295 | * do this by setting MUX0 and MUX1 to '0' 296 | */ 297 | cbi(ADMUX, MUX0); 298 | cbi(ADMUX, MUX1); 299 | } 300 | 301 | // Not needed because free-running mode is enabled. 302 | // Set ADSC in ADCSRA (0x7A) to start another ADC conversion 303 | // sbi(ADCSRA, ADSC); // start ADC measurements 304 | } 305 | -------------------------------------------------------------------------------- /part1/serial-plot-part1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part1/serial-plot-part1.PNG -------------------------------------------------------------------------------- /part2/README.md: -------------------------------------------------------------------------------- 1 | # part 2 - arduino-free-running-analog-read 2 | 3 | Part 2 covers fast reading and smoothing of analog values. Additionally the min values are determined. 4 | 5 | ## bill of material 6 | 7 | * Arduino Uno 8 | * Analog Pressure Sensors (MPX4115AP) 9 | * Capacitors 1µF and 100nF 10 | 11 | ## schematic 12 | 13 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part1/arduino-carb-sync-part1-001.PNG) 14 | 15 | ## serial plot 16 | 17 | The following graph shows the measurement curves of the two pressure sensors. The blue line shows the first pressure sensor (right cylinder), the grenn line the second (left cylinder). The orange an red line depics the minimum values from each cylinder. 18 | 19 | ![Serial Plot](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part2/serial-plot-part2.PNG) 20 | 21 | If the orange and red lines are on top of each other, then the carburettors run synchronously. 22 | -------------------------------------------------------------------------------- /part2/arduino-analogread-freerunning-part2.v0.r2.ino: -------------------------------------------------------------------------------- 1 | // Testing interrupt-based analog reading 2 | // ATMega328p 3 | 4 | // Note, many macro values are defined in and 5 | // , which are included automatically by 6 | // the Arduino interface 7 | 8 | 9 | volatile int readFlag; // High when a value is ready to be read 10 | volatile int analogVal_ADC4; // Value to store analog result from ADC4 11 | volatile int analogVal_ADC5; // Value to store analog result from ADC5 12 | 13 | #define sensor1 4 // left pressure sensor 14 | #define sensor2 5 // right pressure sensor 15 | 16 | #define DEBUG // toogle debug: uncomment-> debug ON 17 | 18 | // Generally, you should use "unsigned long" for variables that hold time 19 | // The value will quickly become too large for an int to store 20 | unsigned long TimeStamp = 0; 21 | unsigned long previousTimeStampMin = 0; 22 | unsigned long TimeStampTemp = 0; 23 | unsigned long TimeStampMin = 20000; 24 | unsigned long TimeStampDiff = 0; 25 | 26 | float RPM; 27 | 28 | int PressureLeft = 1023; 29 | int previousPressureLeft = 1023; 30 | int PressureLeftTemp = 1023; 31 | int PressureLeftMin = 1023; 32 | float PressureLeftFiltered = 1023; 33 | 34 | int PressureRight = 1023; 35 | int previousPressureRight = 1023; 36 | int PressureRightTemp = 1023; 37 | int PressureRightMin = 1023; 38 | float PressureRightFiltered = 1023; 39 | 40 | int DifferenceLeft = 0; 41 | int DifferenceRight = 0; 42 | 43 | const int RANGE = 3; 44 | 45 | #ifndef cbi 46 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 47 | #endif 48 | #ifndef sbi 49 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 50 | #endif 51 | 52 | 53 | void setup() { 54 | Serial.begin(115200); 55 | 56 | pinMode(sensor1, INPUT); 57 | pinMode(sensor2, INPUT); 58 | 59 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 60 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 61 | cbi(ADMUX, ADLAR); 62 | 63 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 64 | // proper source (01) 65 | sbi(ADMUX, REFS0); 66 | cbi(ADMUX, REFS1); 67 | 68 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) 69 | cbi(ADMUX, MUX3); 70 | sbi(ADMUX, MUX2); 71 | cbi(ADMUX, MUX1); 72 | cbi(ADMUX, MUX0); 73 | 74 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 75 | sbi(ADCSRA, ADEN); // enable ADC 76 | 77 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 78 | sbi(ADCSRA, ADATE); // enable auto trigger 79 | 80 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 81 | // This means that as soon as an ADC has finished, the next will be 82 | // immediately started. 83 | cbi(ADCSRB, ADTS2); 84 | cbi(ADCSRB, ADTS1); 85 | cbi(ADCSRB, ADTS0); 86 | 87 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 88 | // Above 200KHz 10-bit results are not reliable. 89 | sbi(ADCSRA, ADPS2); 90 | sbi(ADCSRA, ADPS1); 91 | sbi(ADCSRA, ADPS0); 92 | 93 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 94 | // Without this, the internal interrupt will not trigger. 95 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 96 | 97 | // Enable global interrupts 98 | // AVR macro included in , which the Arduino IDE 99 | // supplies by default. 100 | sei(); 101 | 102 | // Kick off the first ADC 103 | readFlag = 0; 104 | 105 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 106 | sbi(ADCSRA, ADSC); // start ADC measurements 107 | 108 | delay(100); 109 | 110 | // determine difference between senor values 111 | // get some values and find the lowest value 112 | for (int i=0; i <= 1000; i++){ 113 | PressureLeft = analogVal_ADC4; 114 | PressureRight = analogVal_ADC5; 115 | if (PressureLeft < previousPressureLeft) { 116 | previousPressureLeft = PressureLeft; // store the lowest value 117 | } 118 | if (PressureRight < previousPressureRight) { 119 | previousPressureRight = PressureRight; // store the lowest value 120 | } 121 | } 122 | 123 | // compare the lowest values of ADC4 and ADC5, then calculating the difference 124 | if (previousPressureLeft > previousPressureRight){ 125 | DifferenceRight = previousPressureLeft - previousPressureRight; 126 | } else { 127 | DifferenceLeft = previousPressureRight - previousPressureLeft; 128 | } 129 | } 130 | 131 | 132 | // Interrupt service routine for the ADC completion 133 | ISR(ADC_vect){ 134 | // toggling analog input pin between 4 (A4) and 5 (A5) 135 | if (ADMUX == 0x44) { 136 | // Must read low first 137 | analogVal_ADC4 = ADCL | (ADCH << 8); 138 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) to read from ACD5 (0101) 139 | sbi(ADMUX, MUX0); 140 | } else if (ADMUX == 0x45){ 141 | // Must read low first 142 | analogVal_ADC5 = ADCL | (ADCH << 8); 143 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC5 (0101) to read from ACD5 (0100) 144 | cbi(ADMUX, MUX0); 145 | } 146 | } 147 | 148 | 149 | void loop(){ 150 | // calibrate pressure sensors to the same levels 151 | PressureLeft = analogVal_ADC4 + DifferenceLeft; 152 | PressureRight = analogVal_ADC5 + DifferenceRight; 153 | 154 | // filter out noise 155 | if (PressureLeft > (PressureLeftFiltered + RANGE) || PressureLeft < (PressureLeftFiltered - RANGE)) { 156 | PressureLeftFiltered = PressureLeft; 157 | } 158 | if (PressureRight > (PressureRightFiltered + RANGE) || PressureRight < (PressureRightFiltered - RANGE)) { 159 | PressureRightFiltered = PressureRight; 160 | } 161 | 162 | TimeStamp = millis(); 163 | 164 | // check for min values 165 | // The pressure may flutter at the top dead center of the engine. 166 | // To exclude this range, the measurement only starts at a value below 780. 167 | if (PressureLeftFiltered < previousPressureLeft && PressureLeftFiltered < 780) { 168 | PressureLeftTemp = PressureLeftFiltered; 169 | previousTimeStampMin = TimeStampMin; 170 | TimeStampTemp = TimeStamp; 171 | } else { 172 | PressureLeftMin = PressureLeftTemp; 173 | TimeStampMin = TimeStampTemp; 174 | TimeStampDiff = TimeStampMin - previousTimeStampMin; 175 | // In a four-stroke engine that uses a camshaft, each valve is opened every second 176 | // rotation of the crankshaft. According to this the camshaft runs with half speed 177 | // of the crankshaft. Because the time difference is derived from the camshaft (Intake to 178 | // Intake), we have to multiply by 2 to get the speed of the engine. 179 | // RPM = (1 / TimeStampDiff) * MSecPerSec * SecPerMin * 2 180 | // = (1 / TimeStampDiff) * 1000 * 60 * 2 181 | // = (1/ TimeStampDiff) * 120000 182 | RPM = 120000 / TimeStampDiff; 183 | } 184 | 185 | if (PressureRightFiltered < previousPressureRight && PressureRightFiltered < 780) { 186 | PressureRightTemp = PressureRightFiltered; 187 | } else { 188 | PressureRightMin = PressureRightTemp; 189 | } 190 | 191 | #ifdef DEBUG 192 | Serial.print(PressureLeftFiltered); 193 | Serial.print(" "); 194 | #endif 195 | Serial.print(PressureLeftMin); 196 | Serial.print(" "); 197 | #ifdef DEBUG 198 | Serial.print(PressureRightFiltered); 199 | Serial.print(" "); 200 | #endif 201 | Serial.print(PressureRightMin); 202 | Serial.print(" "); 203 | Serial.println(RPM); 204 | 205 | previousPressureLeft = PressureLeftFiltered; 206 | previousPressureRight = PressureRightFiltered; 207 | } 208 | -------------------------------------------------------------------------------- /part2/serial-plot-part2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part2/serial-plot-part2.PNG -------------------------------------------------------------------------------- /part3/README.md: -------------------------------------------------------------------------------- 1 | # arduino-nextion-serial-communication 2 | 3 | Part 3 covers the serial communication between the Arduino an the Nextion display without using the Nextion library. 4 | 5 | ## bill of material 6 | 7 | * Arduino Uno 8 | * Analog Pressure Sensors (MPX4115AP) 9 | * Capacitors 1µF and 100nF 10 | * Nextion NX3224T024_011R 11 | 12 | ## schematic 13 | 14 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part3/arduino-carb-sync-part3-001.PNG) 15 | 16 | ## Nextion layout 17 | 18 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part3/arduino-carb-sync-part3-002.PNG) 19 | -------------------------------------------------------------------------------- /part3/arduino-carb-sync-part3-001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part3/arduino-carb-sync-part3-001.PNG -------------------------------------------------------------------------------- /part3/arduino-carb-sync-part3-002.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part3/arduino-carb-sync-part3-002.PNG -------------------------------------------------------------------------------- /part3/arduino-nextion-serial-communication.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part3/arduino-nextion-serial-communication.HMI -------------------------------------------------------------------------------- /part3/arduino-nextion-serial-communication.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The following sketch is an example of how to send data to the Nextion display without any library. 3 | The data can be text, numbers, or any other atribute of an object. 4 | You can also send System Variables to change settings on the display like: brightness, serial baud rate, etc. 5 | 6 | Connection with Arduino Uno/Nano: 7 | * +5V = 5V 8 | * TX = nonea 9 | * RX = pin 1 (TX) 10 | * GND = GND 11 | */ 12 | 13 | int variable1 = 200; // counter 14 | 15 | 16 | void setup() { 17 | Serial.begin(9600); // Start serial comunication at baud=9600 (default for Nextion) 18 | 19 | delay(500); // give the isplay some time to start 20 | Serial.print("baud=57600"); // Set new baud rate of nextion to 57600, but is temporal. Next time nextion is 21 | // power on, it will retore to default baud of 9600. 22 | // possible baudrates: 9600, 19200, 38400, 57600 und 115200 23 | // To take effect, make sure to reboot the arduino (reseting arduino is not enough). 24 | // If you want to change the default baud, send the command as "bauds=57600", instead of "baud=57600". 25 | // If you change default, everytime the nextion is power on is going to have that baud rate. 26 | // see: https://nextion.itead.cc/resources/documents/instruction-set/ 27 | Serial.write(0xff); // We always have to send this three lines after each command sent to nextion. 28 | Serial.write(0xff); 29 | Serial.write(0xff); 30 | 31 | Serial.end(); // End the serial comunication of baud=9600. 32 | 33 | Serial.begin(57600); // Start serial comunication at baud=57600. 34 | } 35 | 36 | 37 | void loop() { // Put your main code here, to run repeatedly: 38 | variable1--; // decrease the value of the variable by 1. 39 | if(variable1 == 50){ // If the variable reaches 50... 40 | variable1 = 200; // Set the variable to 0 so it starts over again. 41 | } 42 | 43 | 44 | // We are going to send the variable value to the object called s0 (waveform) 45 | // waveform: objectname: s0, id: 1; ch: 4 (four channels 0..3); 46 | // Waveform component only support 8-bit values, 0 minimum, 255 maximum. 47 | 48 | // write to waveform channel 0 49 | Serial.print("add 1,0,"); // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change. 50 | Serial.print(variable1); // This is the value you want to send to that object and atribute mention before. 51 | Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display. 52 | Serial.write(0xff); 53 | Serial.write(0xff); 54 | 55 | // write to waveform channel 1 56 | Serial.print("add 1,1,"); // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change. 57 | Serial.print(variable1 + 5); // This is the value you want to send to that object and atribute mention before. 58 | Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display. 59 | Serial.write(0xff); 60 | Serial.write(0xff); 61 | 62 | // write to waveform channel 2 63 | Serial.print("add 1,2,"); // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change. 64 | Serial.print(variable1 + 10); // This is the value you want to send to that object and atribute mention before. 65 | Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display. 66 | Serial.write(0xff); 67 | Serial.write(0xff); 68 | 69 | // write to waveform channel 3 70 | Serial.print("add 1,3,"); // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change. 71 | Serial.print(variable1 + 15); // This is the value you want to send to that object and atribute mention before. 72 | Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display. 73 | Serial.write(0xff); 74 | Serial.write(0xff); 75 | } // End of loop 76 | -------------------------------------------------------------------------------- /part3/arduino-nextion-serial-communication.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part3/arduino-nextion-serial-communication.tft -------------------------------------------------------------------------------- /part4/Nextion files/arduino-carb-sync-nextion.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part4/Nextion files/arduino-carb-sync-nextion.HMI -------------------------------------------------------------------------------- /part4/Nextion files/arduino-carb-sync-nextion.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part4/Nextion files/arduino-carb-sync-nextion.tft -------------------------------------------------------------------------------- /part4/Nextion files/courier_16.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part4/Nextion files/courier_16.zi -------------------------------------------------------------------------------- /part4/README.md: -------------------------------------------------------------------------------- 1 | # arduino-nextion-serial-communictaion 2 | 3 | Part 4 puts all other parts togehter. 4 | 5 | * freeruning analog read 6 | * smoothing the values 7 | * direct serial communication between Arduino and Nextion Display 8 | * using Nextion waveform 9 | 10 | ## bill of material 11 | 12 | * Arduino Uno 13 | * Analog Pressure Sensors (MPX4115AP) 14 | * Capacitors 1µF and 100nF 15 | * Nextion NX3224T024_011R 16 | 17 | ## schematic 18 | 19 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part4/arduino-carb-sync-part4-001.PNG) 20 | 21 | ## Nextion layout 22 | 23 | ![Nextion Editor](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part4/arduino-carb-sync-part4-002.PNG) 24 | -------------------------------------------------------------------------------- /part4/arduino-carb-sync-nextion.ino: -------------------------------------------------------------------------------- 1 | // interrupt-based analog reading with Arduino's ATMega328p 2 | // to measure pressure sensor values for synchronisation of 3 | // two motorcycle carburators 4 | // https://github.com/yz88/arduino-digital-carb-sync/ 5 | 6 | 7 | volatile int readFlag; // High when a value is ready to be read 8 | volatile int analogVal_ADC4; // Value to store analog result from ADC4 9 | volatile int analogVal_ADC5; // Value to store analog result from ADC5 10 | unsigned long time; 11 | 12 | #define sensor1 4 // left pressure sensor 13 | #define sensor2 5 // right pressure sensor 14 | 15 | //#define DEBUG // toogle debug: uncomment-> debug ON 16 | 17 | int PressureLeft = 1023; 18 | int previousPressureLeft = 1023; 19 | int PressureLeftTemp = 1023; 20 | int PressureLeftMin = 1023; 21 | float PressureLeftFiltered = 1023; 22 | 23 | int PressureRight = 1023; 24 | int previousPressureRight = 1023; 25 | int PressureRightTemp = 1023; 26 | int PressureRightMin = 1023; 27 | float PressureRightFiltered = 1023; 28 | 29 | int DifferenceLeft = 0; 30 | int DifferenceRight = 0; 31 | 32 | const int RANGE = 3; 33 | 34 | #ifndef cbi 35 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 36 | #endif 37 | #ifndef sbi 38 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 39 | #endif 40 | 41 | 42 | void setup() { 43 | // Start serial comunication at baud=9600 (default for Nextion display) 44 | Serial.begin(9600); 45 | 46 | // give the Nextion display some time to start 47 | delay(500); 48 | 49 | // Set new baud rate for Nextion display to 115200 50 | Serial.print("baud=115200"); 51 | Serial.write(0xff); 52 | Serial.write(0xff); 53 | Serial.write(0xff); 54 | 55 | // End the serial comunication of baud=9600. 56 | Serial.end(); 57 | // start serial comunication at baud=115200. 58 | Serial.begin(115200); 59 | 60 | // initialise Arduino's input pins 61 | pinMode(sensor1, INPUT); 62 | pinMode(sensor2, INPUT); 63 | 64 | // settign Arduino's registers for freerunning anlaog read 65 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 66 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 67 | cbi(ADMUX, ADLAR); 68 | 69 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 70 | // proper source (01) 71 | sbi(ADMUX, REFS0); 72 | cbi(ADMUX, REFS1); 73 | 74 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) 75 | cbi(ADMUX, MUX3); 76 | sbi(ADMUX, MUX2); 77 | cbi(ADMUX, MUX1); 78 | cbi(ADMUX, MUX0); 79 | 80 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 81 | sbi(ADCSRA, ADEN); // enable ADC 82 | 83 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 84 | sbi(ADCSRA, ADATE); // enable auto trigger 85 | 86 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 87 | // This means that as soon as an ADC has finished, the next will be 88 | // immediately started. 89 | cbi(ADCSRB, ADTS2); 90 | cbi(ADCSRB, ADTS1); 91 | cbi(ADCSRB, ADTS0); 92 | 93 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 94 | // Above 200KHz 10-bit results are not reliable. 95 | sbi(ADCSRA, ADPS2); 96 | sbi(ADCSRA, ADPS1); 97 | sbi(ADCSRA, ADPS0); 98 | 99 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 100 | // Without this, the internal interrupt will not trigger. 101 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 102 | 103 | // Enable global interrupts 104 | // AVR macro included in , which the Arduino IDE 105 | // supplies by default. 106 | sei(); 107 | 108 | // Kick off the first ADC 109 | readFlag = 0; 110 | 111 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 112 | sbi(ADCSRA, ADSC); // start ADC measurements 113 | 114 | delay(100); 115 | 116 | // etermine difference between senor values 117 | // get some values and find the lowest value 118 | for (int i=0; i <= 1000; i++){ 119 | PressureLeft = analogVal_ADC4; 120 | PressureRight = analogVal_ADC5; 121 | if (PressureLeft < previousPressureLeft) { 122 | previousPressureLeft = PressureLeft; // store the lowest value 123 | } 124 | if (PressureRight < previousPressureRight) { 125 | previousPressureRight = PressureRight; // store the lowest value 126 | } 127 | } 128 | 129 | // compare the lowest values of ADC4 and ADC5, then calculating the difference 130 | if (previousPressureLeft > previousPressureRight){ 131 | DifferenceRight = previousPressureLeft - previousPressureRight; 132 | } else { 133 | DifferenceLeft = previousPressureRight - previousPressureLeft; 134 | } 135 | } 136 | 137 | 138 | // Interrupt service routine for the ADC completion 139 | ISR(ADC_vect){ 140 | // toggling analog input pin between 4 (A4) and 5 (A5) 141 | if (ADMUX == 0x44) { 142 | // Must read low first 143 | analogVal_ADC4 = ADCL | (ADCH << 8); 144 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) to read from ACD5 (0101) 145 | sbi(ADMUX, MUX0); 146 | } else if (ADMUX == 0x45){ 147 | // Must read low first 148 | analogVal_ADC5 = ADCL | (ADCH << 8); 149 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC5 (0101) to read from ACD5 (0100) 150 | cbi(ADMUX, MUX0); 151 | } 152 | } 153 | 154 | 155 | void loop(){ 156 | // calibrate pressure sensors to the same level 157 | PressureLeft = analogVal_ADC4 + DifferenceLeft; 158 | PressureRight = analogVal_ADC5 + DifferenceRight; 159 | 160 | // filter out noise, the measured value The input signals vary in value by one up and down. 161 | if (PressureLeft > (PressureLeftFiltered + RANGE) || PressureLeft < (PressureLeftFiltered - RANGE)) { 162 | PressureLeftFiltered = PressureLeft; 163 | } 164 | if (PressureRight > (PressureRightFiltered + RANGE) || PressureRight < (PressureRightFiltered - RANGE)) { 165 | PressureRightFiltered = PressureRight; 166 | } 167 | 168 | // check for min values 169 | // The pressure may flutter at the top dead center of the engine. 170 | // To exclude this range, the measurement only starts at a value below 780. 171 | if (PressureLeftFiltered < previousPressureLeft && PressureLeftFiltered < 780) { 172 | PressureLeftTemp = PressureLeftFiltered; 173 | } else { 174 | PressureLeftMin = PressureLeftTemp; 175 | } 176 | 177 | if (PressureRightFiltered < previousPressureRight && PressureRightFiltered < 780) { 178 | PressureRightTemp = PressureRightFiltered; 179 | } else { 180 | PressureRightMin = PressureRightTemp; 181 | } 182 | 183 | #ifdef DEBUG 184 | Serial.print("add 1,0,"); 185 | // Nextion display waveform accepts values between 0 - 255 186 | // Measured values are in the range from 850 down to 400, thus divide the 187 | // values by 5 to fit the waveform's value range 188 | Serial.print((int)PressureLeftFiltered/5); 189 | Serial.write(0xff); 190 | Serial.write(0xff); 191 | Serial.write(0xff); 192 | #endif 193 | 194 | Serial.print("add 1,1,"); 195 | Serial.print((int)PressureLeftMin/5); 196 | Serial.write(0xff); 197 | Serial.write(0xff); 198 | Serial.write(0xff); 199 | 200 | #ifdef DEBUG 201 | Serial.print("add 1,2,"); 202 | Serial.print((int)PressureRightFiltered/5); 203 | Serial.write(0xff); 204 | Serial.write(0xff); 205 | Serial.write(0xff); 206 | #endif 207 | 208 | Serial.print("add 1,3,"); 209 | Serial.print((int)PressureRightMin/5); 210 | Serial.write(0xff); 211 | Serial.write(0xff); 212 | Serial.write(0xff); 213 | 214 | previousPressureLeft = PressureLeftFiltered; 215 | previousPressureRight = PressureRightFiltered; 216 | } 217 | -------------------------------------------------------------------------------- /part4/arduino-carb-sync-part4-001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part4/arduino-carb-sync-part4-001.PNG -------------------------------------------------------------------------------- /part4/arduino-carb-sync-part4-002.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part4/arduino-carb-sync-part4-002.PNG -------------------------------------------------------------------------------- /part5/Nextion files/arduino-carb-sync-nextion-part5.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part5/Nextion files/arduino-carb-sync-nextion-part5.HMI -------------------------------------------------------------------------------- /part5/Nextion files/arduino-carb-sync-nextion-part5.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part5/Nextion files/arduino-carb-sync-nextion-part5.tft -------------------------------------------------------------------------------- /part5/Nextion files/courier_16.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part5/Nextion files/courier_16.zi -------------------------------------------------------------------------------- /part5/README.md: -------------------------------------------------------------------------------- 1 | # arduino-nextion-serial-communictaion 2 | 3 | Part 5 uses Nextion's progressbar instead of waveform. 4 | 5 | * freeruning analog read 6 | * smoothing the values 7 | * direct serial communication between Arduino and Nextion Display 8 | * using Nextion progressbar 9 | 10 | ## bill of material 11 | 12 | * Arduino Uno 13 | * Analog Pressure Sensors (MPX4115AP) 14 | * Capacitors 1µF and 100nF 15 | * Nextion NX3224T024_011R 16 | 17 | ## schematic 18 | 19 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part5/arduino-carb-sync-part5-001.PNG) 20 | 21 | ## Nextion layout 22 | 23 | ![Nextion Editor](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part5/arduino-carb-sync-part5-002.PNG) 24 | 25 | ## Demo video 26 | 27 | https://youtu.be/DKk2O86xgPw 28 | -------------------------------------------------------------------------------- /part5/arduino-analogread-freerunning-part5.v0.r0.ino: -------------------------------------------------------------------------------- 1 | // interrupt-based analog reading with Arduino's ATMega328p 2 | // to measure pressure sensor values for synchronisation of 3 | // two motorcycle carburators 4 | // https://github.com/yz88/arduino-digital-carb-sync/ 5 | 6 | 7 | volatile int readFlag; // High when a value is ready to be read 8 | volatile int analogVal_ADC4; // Value to store analog result from ADC4 9 | volatile int analogVal_ADC5; // Value to store analog result from ADC5 10 | unsigned long time; 11 | 12 | #define sensor1 5 // left pressure sensor 13 | #define sensor2 4 // right pressure sensor 14 | 15 | //#define DEBUG // toogle debug: uncomment-> debug ON 16 | 17 | // Generally, you should use "unsigned long" for variables that hold time 18 | // The value will quickly become too large for an int to store 19 | unsigned long TimeStamp = 0; 20 | unsigned long previousTimeStampMin = 0; 21 | unsigned long TimeStampTemp = 0; 22 | unsigned long TimeStampMin = 20000; 23 | unsigned long TimeStampDiff = 0; 24 | 25 | float RPM; 26 | 27 | float PressureLeft = 1023; 28 | float previousPressureLeft = 1023; 29 | float PressureLeftTemp = 1023; 30 | float PressureLeftMin = 1023; 31 | float PressureLeftFiltered = 1023; 32 | 33 | float PressureRight = 1023; 34 | float previousPressureRight = 1023; 35 | float PressureRightTemp = 1023; 36 | float PressureRightMin = 1023; 37 | float PressureRightFiltered = 1023; 38 | 39 | int DifferenceLeft = 0; 40 | int DifferenceRight = 0; 41 | 42 | const int RANGE = 3; 43 | 44 | #ifndef cbi 45 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 46 | #endif 47 | #ifndef sbi 48 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 49 | #endif 50 | 51 | 52 | void setup() { 53 | // Start serial comunication at baud=9600 (default for Nextion display) 54 | Serial.begin(9600); 55 | 56 | // give the Nextion display some time to start 57 | delay(500); 58 | 59 | // Set new baud rate for Nextion display to 115200 60 | Serial.print("baud=115200"); 61 | Serial.write(0xff); 62 | Serial.write(0xff); 63 | Serial.write(0xff); 64 | 65 | // End the serial comunication of baud=9600. 66 | Serial.end(); 67 | // start serial comunication at baud=115200. 68 | Serial.begin(115200); 69 | 70 | // initialise Arduino's input pins 71 | pinMode(sensor1, INPUT); 72 | pinMode(sensor2, INPUT); 73 | 74 | // settign Arduino's registers for freerunning anlaog read 75 | // clear ADLAR in ADMUX (0x7C) to right-adjust the result 76 | // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) 77 | cbi(ADMUX, ADLAR); 78 | 79 | // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the 80 | // proper source (01) 81 | sbi(ADMUX, REFS0); 82 | cbi(ADMUX, REFS1); 83 | 84 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) 85 | cbi(ADMUX, MUX3); 86 | sbi(ADMUX, MUX2); 87 | cbi(ADMUX, MUX1); 88 | cbi(ADMUX, MUX0); 89 | 90 | // Set ADEN in ADCSRA (0x7A) to enable the ADC. 91 | sbi(ADCSRA, ADEN); // enable ADC 92 | 93 | // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. 94 | sbi(ADCSRA, ADATE); // enable auto trigger 95 | 96 | // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running (000). 97 | // This means that as soon as an ADC has finished, the next will be 98 | // immediately started. 99 | cbi(ADCSRB, ADTS2); 100 | cbi(ADCSRB, ADTS1); 101 | cbi(ADCSRB, ADTS0); 102 | 103 | // Set ADPS2:0: ADC Prescaler Select Bits to 128 (111) (16000KHz/128 = 125KHz) 104 | // Above 200KHz 10-bit results are not reliable. 105 | sbi(ADCSRA, ADPS2); 106 | sbi(ADCSRA, ADPS1); 107 | sbi(ADCSRA, ADPS0); 108 | 109 | // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. 110 | // Without this, the internal interrupt will not trigger. 111 | sbi(ADCSRA, ADIE); // enable ADC interrupt when measurement complete 112 | 113 | // Enable global interrupts 114 | // AVR macro included in , which the Arduino IDE 115 | // supplies by default. 116 | sei(); 117 | 118 | // Kick off the first ADC 119 | readFlag = 0; 120 | 121 | // Set ADSC: ADC Start Conversion in ADCSRA (0x7A) to start the ADC conversion 122 | sbi(ADCSRA, ADSC); // start ADC measurements 123 | 124 | delay(100); 125 | 126 | // etermine difference between senor values 127 | // get some values and find the lowest value 128 | for (int i=0; i <= 1000; i++){ 129 | PressureLeft = analogVal_ADC5; 130 | PressureRight = analogVal_ADC4; 131 | if (PressureLeft < previousPressureLeft) { 132 | previousPressureLeft = PressureLeft; // store the lowest value 133 | } 134 | if (PressureRight < previousPressureRight) { 135 | previousPressureRight = PressureRight; // store the lowest value 136 | } 137 | } 138 | 139 | // compare the lowest values of ADC4 and ADC5, then calculating the difference 140 | if (previousPressureLeft > previousPressureRight){ 141 | DifferenceRight = previousPressureLeft - previousPressureRight; 142 | } else { 143 | DifferenceLeft = previousPressureRight - previousPressureLeft; 144 | } 145 | } 146 | 147 | 148 | // Interrupt service routine for the ADC completion 149 | ISR(ADC_vect){ 150 | // toggling analog input pin between 4 (A4) and 5 (A5) 151 | if (ADMUX == 0x44) { 152 | // Must read low first 153 | analogVal_ADC4 = ADCL | (ADCH << 8); 154 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC4 (0100) to read from ACD5 (0101) 155 | sbi(ADMUX, MUX0); 156 | } else if (ADMUX == 0x45){ 157 | // Must read low first 158 | analogVal_ADC5 = ADCL | (ADCH << 8); 159 | // Set MUX3..0 in ADMUX (0x7C) to read from ADC5 (0101) to read from ACD5 (0100) 160 | cbi(ADMUX, MUX0); 161 | } 162 | } 163 | 164 | 165 | void loop(){ 166 | // calibrate pressure sensors to the same level 167 | PressureLeft = analogVal_ADC5 + DifferenceLeft; 168 | PressureRight = analogVal_ADC4 + DifferenceRight; 169 | 170 | // filter out noise, the measured value The input signals vary in value by one up and down. 171 | if (PressureLeft > (PressureLeftFiltered + RANGE) || PressureLeft < (PressureLeftFiltered - RANGE)) { 172 | PressureLeftFiltered = PressureLeft; 173 | } 174 | if (PressureRight > (PressureRightFiltered + RANGE) || PressureRight < (PressureRightFiltered - RANGE)) { 175 | PressureRightFiltered = PressureRight; 176 | } 177 | 178 | TimeStamp = millis(); 179 | 180 | // check for min values 181 | // The pressure may flutter at the top dead center of the engine. 182 | // To exclude this range, the measurement only starts at a value below 780. 183 | if (PressureLeftFiltered < previousPressureLeft && PressureLeftFiltered < 780) { 184 | PressureLeftTemp = PressureLeftFiltered; 185 | previousTimeStampMin = TimeStampMin; 186 | TimeStampTemp = TimeStamp; 187 | } else { 188 | PressureLeftMin = PressureLeftTemp; 189 | TimeStampMin = TimeStampTemp; 190 | TimeStampDiff = TimeStampMin - previousTimeStampMin; 191 | // In a four-stroke engine that uses a camshaft, each valve is opened every second 192 | // rotation of the crankshaft. According to this the camshaft runs with half speed 193 | // of the crankshaft. Because the time difference is derived from the camshaft (Intake to 194 | // Intake), we have to multiply by 2 to get the speed of the engine. 195 | // RPM = (1 / TimeStampDiff) * MSecPerSec * SecPerMin * 2 196 | // = (1 / TimeStampDiff) * 1000 * 60 * 2 197 | // = (1/ TimeStampDiff) * 120000 198 | RPM = 120000 / TimeStampDiff; 199 | } 200 | 201 | if (PressureRightFiltered < previousPressureRight && PressureRightFiltered < 780) { 202 | PressureRightTemp = PressureRightFiltered; 203 | } else { 204 | PressureRightMin = PressureRightTemp; 205 | } 206 | 207 | Serial.print("j0.val="); 208 | // Nextion display progressbar accepts values between 0 - 100 209 | // Measured values are in the range from 850 down to 400, therefore 210 | // the values have to be normalized 211 | Serial.print((int)((PressureLeftMin-1)/(1024-1)*100)); 212 | Serial.write(0xff); 213 | Serial.write(0xff); 214 | Serial.write(0xff); 215 | 216 | Serial.print("j1.val="); 217 | Serial.print((int)((PressureRightMin-1)/(1024-1)*100)); 218 | Serial.write(0xff); 219 | Serial.write(0xff); 220 | Serial.write(0xff); 221 | 222 | Serial.print("n0.val="); 223 | Serial.print((int)RPM); 224 | Serial.write(0xff); 225 | Serial.write(0xff); 226 | Serial.write(0xff); 227 | 228 | previousPressureLeft = PressureLeftFiltered; 229 | previousPressureRight = PressureRightFiltered; 230 | } 231 | -------------------------------------------------------------------------------- /part5/arduino-carb-sync-part5-001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part5/arduino-carb-sync-part5-001.PNG -------------------------------------------------------------------------------- /part5/arduino-carb-sync-part5-002.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part5/arduino-carb-sync-part5-002.PNG -------------------------------------------------------------------------------- /part6/Nextion files/arduino-carb-sync-with-battery.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part6/Nextion files/arduino-carb-sync-with-battery.HMI -------------------------------------------------------------------------------- /part6/Nextion files/arduino-carb-sync-with-battery.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part6/Nextion files/arduino-carb-sync-with-battery.tft -------------------------------------------------------------------------------- /part6/Nextion files/courier_16.zi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part6/Nextion files/courier_16.zi -------------------------------------------------------------------------------- /part6/README.md: -------------------------------------------------------------------------------- 1 | # arduino-nextion-serial-communictaion 2 | 3 | Part 6 is a spezial version that displays the pressure as well as the battery voltage from a LiFePo4 (4s2p) motorcycle battery 4 | 5 | * freeruning analog read 6 | * smoothing the values 7 | * direct serial communication between Arduino and Nextion Display 8 | * using Nextion progressbar 9 | 10 | ## status 11 | 12 | WORK IN PROGRESS 13 | 14 | ## bill of material 15 | 16 | * Arduino Uno 17 | * Analog Pressure Sensors (MPX4115AP) 18 | * Capacitors 1µF and 100nF 19 | * Nextion NX3224T024_011R 20 | * LiFePo4 motorcycle battery with balancer connector 21 | 22 | ## schematic 23 | 24 | ![Fritzing](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part6/arduino-carb-sync-part6-001.PNG) 25 | 26 | ## Nextion layout 27 | 28 | ![Nextion Editor](https://github.com/yz88/arduino-digital-carb-sync/blob/master/part6/arduino-carb-sync-part6-002.PNG) 29 | -------------------------------------------------------------------------------- /part6/arduino-carb-sync-part6-001.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part6/arduino-carb-sync-part6-001.PNG -------------------------------------------------------------------------------- /part6/arduino-carb-sync-part6-002.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/part6/arduino-carb-sync-part6-002.PNG -------------------------------------------------------------------------------- /pressure-intake-duct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yz88/arduino-digital-carb-sync/74bef8462f5c934986ac20f93f40ac550e598233/pressure-intake-duct.png --------------------------------------------------------------------------------