home register FAQ memberlist calendar

Go Back   Turbobricks Forums > Mechanical > performance & modifications > aftermarket engine management

Reply
 
Thread Tools Display Modes
Old 05-05-2021, 09:47 PM   #26
142 guy
Board Member
 
Join Date: May 2014
Location: Saskatchewan, Canada
Default

Quote:
Originally Posted by VB242 View Post
I know Toyota COPs have a feedback wire that are used to detect misfires, not exactly sure how, perhaps a piezo sensor in the COP?
Cars have have one of two misfire detection systems, or both. One looks at crankshaft speed fluctuations and the other monitors ignition coil output voltage. I have an Acura and it has two complete sets of P codes for misfires, one triggered by the signal (or lack of signal) from the ignition coil , the other triggered by monitoring the crankshaft speed. The Acura I have has COPs; but, they are passive COPs and the misfire monitoring circuit is just a voltage divider that generates a voltage pulse when the ignition coil fires. That pulse goes to an external misfire detection module which generates a conditioned signal for the ECU. The ECU initiates a spark trigger for the coil and probably waits for the signal from the misfire detection module to confirm that the coil did fire. If there is no confirmation signal it probably sets a P code. That system will only detect misfires caused by an ignition failure, not misfires cause by a fuel mixture problem or other problems. The crankshaft speed monitor will pick up misfires due to all causes, including stuff that are not legitimate misfires if the software is set too sensitive.
142 guy is offline   Reply With Quote
Old 05-07-2021, 08:01 AM   #27
apollokid
Newbie
 
apollokid's Avatar
 
Join Date: Aug 2020
Location: Milan (Italy)
Default

Quote:
Originally Posted by bobxyz View Post
I thought I was close to done, but then realized that the Leonardo/32U4 microcontroller has NO hysteresis on the input pins, plus weird input voltage levels. The original Uno/328P boards have reasonable input hysteresis and levels. Without the hysteresis, the inputs will be _very_ sensitive to the slightest electrical noise. I'm really surprised that Arduino would pick a chip without any input hysteresis for hobbyist use. WTF were they thinking.
I'm using an Arduino Mega 2560 but from the manual also the Atmega16U4/32U4 have Schmitt triggers on digital inputs (see chapter 13.2 Ports as General Digital I/O)
https://ww1.microchip.com/downloads/..._Datasheet.pdf



In the while I've totally destroyed my board and rebuilt it using diodes to clamp the spikes and some LM339 comparators instead of optoisolators to change the voltage level. For the analog signals I still used OpAmps powered at 5V + some filters.
At the bench it works but I'm still not yet satisfied, infact I'm worried by the LM339 sinced it doesn't like negative voltages lower than -0.3V, and this is less of what I can cut using diodes.
Also the input impedance it's driving me crazy since I would like to have it much grather as possibile but this is in conflict with the need to have a good voltage precision (especially with OpAmps that handle analog signals for ECT, AMM, O2 sensor and battery voltage).
I started with resistors of 1MΩ but now I'm using only 10kΩ in series with the input pins of both OpAmps and Comparators thanks the high input impedance of OpAmps and Comparators.

I'm better studing it and the "Application design manual"...

Yesterday evening I wrote my first code that uses pin change interrupts and registers and it worked (I had also to fix the conflict with my code that was due to the dependency to the library SoftwareSerial that I don't use at runtime), now that I learned how it works it is easy, but the code is much more cryptical to read since it requires to enter more deeply into the hardware

In the next days I will rewrite also the other signals handling routines and I will made some measures to see how much is faster than digitalRead()...

This is the new code to measure injectors pulse width:



...

// PCINT16 alias PK0 alias A8

// Configure PCINT16 as an input using the Data Direction Register K (DDRK)
DDRK &= ~_BV(PCINT16);

// Disable the pull-up resistor on PCINT16 using the Port K Data Register (PORTK)
PORTK &= ~_BV(PCINT16);

// Enable pin change interrupt on the PCINT16 pin using Pin Change Mask Register 2 (PCMSK2)
PCMSK2 = _BV(PCINT16);

// Enable pin change interrupt 2 using the Pin Change Interrrupt Control Register (PCICR)
PCICR |= _BV(PCIE2);

// Enable interrupts
sei();

...

ISR(PCINT2_vect) {
unsigned long enterTime = micros();
uint8_t injectorPinStatus = PINK & _BV(PINK0); // Read PK0 using the Port K Pin Input Register (PINK)
if (prevInjectorsStatus != injectorPinStatus) {
if (injectorPinStatus) {
// injectors off
if (lastInjectorsActivationMicros > 0) {
injectorsTonMicros = enterTime - lastInjectorsActivationMicros;
}
lastInjectorsActivationMicros = 0;
}
else {
// injectors on
lastInjectorsActivationMicros = enterTime;
}

prevInjectorsStatus = injectorPinStatus;
}
}



...

Last edited by apollokid; 05-07-2021 at 05:35 PM.. Reason: rewritten initialization registers code to be more readable
apollokid is offline   Reply With Quote
Old 05-08-2021, 02:11 PM   #28
142 guy
Board Member
 
Join Date: May 2014
Location: Saskatchewan, Canada
Default

I am a clumsy C programmer; but, my understanding is that time functions should not be used within the ISR. In your ISR, you are initializing entertime using the micros() function. The micros() function returns the number of microseconds since the board started running the current code. The information I recall is that when called within an ISR micros() can provide erratic results once the operating time exceeds 2 milliseconds.

Since I have never tried using micros() within an ISR, I don't know what the nature of this erratic behavior is. If the problem is that it returns a time with an error of a few microseconds that may not be significant when evaluating the accuracy of the injector pulse width. Perhaps you are aware of the micros() problem and have determined that is not a problem for what you are doing.

I didn't check explicitly; but, it looks like you have dealt with the micros() overflow problem.
142 guy is offline   Reply With Quote
Old 05-09-2021, 05:25 PM   #29
apollokid
Newbie
 
apollokid's Avatar
 
Join Date: Aug 2020
Location: Milan (Italy)
Default

I think is not a problem of be a great C/C++ programmer, is to have a deep knowledge of the arduino architecture.
The micros() function relies on an HarwareTimer and HarwareTimers throw a software interrupt every time they run into overflow to increment a counter (necessary to know how much time has elapsed from the boot).
I think that using micros() inside a ISR could suffer problems if called more times since if the HarwareTimer runs into overflow between one call and the other the second call will return a time that precedes the one returned by the first call since the counter increment will be deplayed after the ISR ends.
If micros() is called only once at the beginning of a fast ISR I don't think it could be a real problem.
I was better reading the documentation and one problem using micros() is that on most arduino boards it has a precision of 4μs and this could explain why, also after having rebuild my interface using comparators instead of optoisolators, the minimum pulse width of a Tq pulse I can measure is still approx to 10μs.
May be that modifying the prescaler of the timers it is possibile to improve the precision but before doing a such thing I have to study much better the consequences since the timers are used also by other functions and/or libraries.
Consider that I'm still learning day by day new things about arduino and I could change my point of view in the future, but I also have to say that to measure injectors pulses (or engine rpm) the micros() function inside a ISR seems to work fine (and also for measuring the Tq signal, also if with a moderate precision). For other signals like IAC or vehicle speed I think that a ISR is not the proper solution and I believe that it could be better to call pulseWidth() with a short timeout inside a polling loop (the same to sample analog signals).
apollokid is offline   Reply With Quote
Old 05-09-2021, 08:23 PM   #30
bobxyz
Board Member
 
bobxyz's Avatar
 
Join Date: Aug 2014
Location: Boulder CO
Default

Status: I'm still looking at options to use an Arduino Leonardo 32U4 cpu with external buffer circuits to give good hysteresis and noise tolerance. I want to stay with the 32U4 so that I can use a hardware serial port for the HC-05 Bluetooth board. It's not a max baud rate issue, but I don't trust the standard "software serial library" to work well with my extra interrupt code. Writing good and glitch-free interrupt code can be difficult, and I've seen problems sharing interrupts with common LCD graphics and CAN bus libraries.

Hysteresis: The some of the Atmel/Microchip AVR datasheets included graphs of hysteresis, some don't. Without a graph, you can still infer the hysteresis from the charts of Vih and Vol levels (see Pin Threshold section). The Uno 328P datasheet shows ~500mV of hysteresis (Vih,typ - Vil,typ), which gives good noise immunity. The Leonardo 32U4 shows only ~25mV, which gives almost no noise tolerance. Your Mega board's 2560 cpu has ~400mV of hysteresis, which is good.

More Status: I've pretty much given up on the option of having a 100% thru-hole PCB -- the added signal buffering takes too many parts. I'm hoping that the JCLpcb SMT assembly has high quality because I really struggle with any SMT work. The latest plans are to use dual 5v schmitt trigger buffers, 74LVC2G17 in a SOT-363 pkg, with +/- clamp diodes to provide hysteresis and level-shift the inputs. You can get dual series schottky barrier diodes in a SOT-323 pkg (BAT54SWT), so there should be plenty of room. For the initial PCBs, I'd like to use the UNO/Leonardo R3 shield form factor. I think this will plug onto your Mega board too (but you may need some jumper wires because some of the pin change interrupts are on different pins).

Clamping undershoot: To clamp signals with a minimum voltage difference, look for a "schottky barrier diode". These will typically clamp at a bit less then 0.3v at low currents. I forget the common thru-hole part numbers.

Interrupts: Once you're comfortable with the pin-change interrupts, you can use them to measure any pulse parameters directly. After you're setup and understand how to measure one pin, the rest are just slight modifications. Besides, I'm not sure if the pulseIn() function will play nicely with other interrupt-driven code.

Micros(): I forget where I found the documentation, but the micros() function should be fine to use within an interrupt routine. There might be problems if you have very long interrupt code. If it's too long, your routine has disabled interrupts, and the micros() code can't execute its counter rollover interrupt code until your routine is done.

Normally, you don't want to add any unmatched sei() interrupt enables to your main code. Generally, if you need interrupts disabled in main code, you do a: cli(); ; sei(); . Remember, the Arduino environment is already using interrupts (for timing and for serial) and that you need to share nicely.
bobxyz is offline   Reply With Quote
Old 05-19-2021, 11:09 PM   #31
bobxyz
Board Member
 
bobxyz's Avatar
 
Join Date: Aug 2014
Location: Boulder CO
Default

Status Du Jour: Design, parts selection, and schematics are good. Initial PCB sizing, to match an Arduino Leonardo R3 Shield, and placement seem fine. Learning the layout tools and routing is underway. The EasyEDA tools include a slick 3D viewer. I'm sure glad I'm not doing the SMT assembly (and I've already picked the biggest available packages). The 3D picture here is close to the actual board size of 2.1"x2.7" (or at least it is on my screen).



-Bob
bobxyz is offline   Reply With Quote
Old 05-20-2021, 03:58 PM   #32
hk 40
Board Member
 
hk 40's Avatar
 
Join Date: May 2011
Location: RTP, North Carolina
Default

Ive followed this with much interest and great respect. I just want to ask why you guys are using such boring displays. If the arduino has character maps you can easily use full dot matrix displays and designed cool plugins for your LH creations. If had a bit of exposure to displays and the hd44780 is basic and old. may I suggest looking at Noritake vacuum florescent displays. If you really want your visuals to shine this is the way. The 3900 series can even play AVI's in there bright monochrome appearance have a look. The are dual mode meaning they a smart serial and parallel and can show the separately in different screen areas.

These are some of the smartest and coolest graphic lcd's on the market. They will add flair an more capabilities to your visuals. Much more advanced than matrix orbitals or the 4x20 alphanumeric lcd's
https://www.noritake-elec.com/

This is a link to some old LCD forums now in repository.
https://lcdhype.condense.de/
http://www.lcdstudio.com/site20/home.php
there are some plugins ,drivers and wiring diagrams are still there but the Noritakes are smart serial thru db9.



I played in this world some time ago. What you do sparks my interest. Show a sale rep in your area your project and ull likely receive and offer to meet with free samples....cool company....

Regards
Hubert
__________________
Original Join date 5-21-2003

assuming we have an electrical circuit containing a power source and a solenoid of inductance L , we can write the equation of magnetic energy, E , stored in the inductor as: E = 1/2 * L * I² , where I is the current flowing through the wire

I have an ecu which has 8 channels of full sequential fuel and ignition control .
hk 40 is offline   Reply With Quote
Old 05-27-2021, 11:21 PM   #33
bobxyz
Board Member
 
bobxyz's Avatar
 
Join Date: Aug 2014
Location: Boulder CO
Default

I stayed up late last night and finished off the PCB design. Sent my money off to 深圳市嘉立创科技发展有限公司 and the stuffed boards are finally underway.

I gotta say, I'm still in shock at the prices:
- $5 for 10 blank PCBs (on special)
- $8.50 for mfg setup and solder paste stencil
- 2x $3 for "Extended" parts that they need to hand load (versus "Basic" parts that are already loaded for the pick&place machine)
- $7 for hand soldering the DB-15 connectors (I didn't have any in my parts stash, so why not)
- ~$1.50 per board in parts - roughly:
-- a penny for each R and C
-- a nickle for diodes and small logic gates
-- $0.20 for the 5v regulator
-- $0.35 for the DB-15 connector
- $13 for 2-4day DHL shipping
- -$10 new customer discount code
----------
$45 for 10 [mostly] assembled PCBs (shown ~2x, actual size is 2.1" x 2.7")




I still remember being happy years ago with 3 blank boards for $99, and hundreds of dollars for short run SMT assembly. Wow, how this has all changed.

The boards should be here in a couple weeks. If anyone wants one, send me a message. It would probably be best to wait until I do some basic testing and get the initial software working first. You'll need an Arduino Leonardo, some 0.1" headers, a MPX MAP sensor [optional], a HC-05 bluetooth module [initially optional] and some DB-9 connectors (or other) for wiring to the EZK/ECU boxes.

-Bob

Last edited by bobxyz; 05-27-2021 at 11:51 PM..
bobxyz is offline   Reply With Quote
Old 05-28-2021, 06:01 AM   #34
hk 40
Board Member
 
hk 40's Avatar
 
Join Date: May 2011
Location: RTP, North Carolina
Default

Quote:
Originally Posted by bobxyz View Post
I stayed up late last night and finished off the PCB design. Sent my money off to 深圳市嘉立创科技发展有限公司 and the stuffed boards are finally underway.

I gotta say, I'm still in shock at the prices:
- $5 for 10 blank PCBs (on special)
- $8.50 for mfg setup and solder paste stencil
- 2x $3 for "Extended" parts that they need to hand load (versus "Basic" parts that are already loaded for the pick&place machine)
- $7 for hand soldering the DB-15 connectors (I didn't have any in my parts stash, so why not)
- ~$1.50 per board in parts - roughly:
-- a penny for each R and C
-- a nickle for diodes and small logic gates
-- $0.20 for the 5v regulator
-- $0.35 for the DB-15 connector
- $13 for 2-4day DHL shipping
- -$10 new customer discount code
----------
$45 for 10 [mostly] assembled PCBs (shown ~2x, actual size is 2.1" x 2.7")




I still remember being happy years ago with 3 blank boards for $99, and hundreds of dollars for short run SMT assembly. Wow, how this has all changed.

The boards should be here in a couple weeks. If anyone wants one, send me a message. It would probably be best to wait until I do some basic testing and get the initial software working first. You'll need an Arduino Leonardo, some 0.1" headers, a MPX MAP sensor [optional], a HC-05 bluetooth module [initially optional] and some DB-9 connectors (or other) for wiring to the EZK/ECU boxes.

-Bob
Beautiful work!
Regards
Hubert
hk 40 is offline   Reply With Quote
Old 06-04-2021, 03:40 AM   #35
apollokid
Newbie
 
apollokid's Avatar
 
Join Date: Aug 2020
Location: Milan (Italy)
Default

Thumb up Bob, congratulations for the progresses
I paused my works after having rebuilt the prototype board, at the moment I'm still waiting for some schottky diodes from aliexpress and since holidays are coming I think I will restart works after them.
For the 3D picture of the board, also Kikad has this feature and I find it really great!

Quote:
Originally Posted by hk 40 View Post
[CENTER]Ive followed this with much interest and great respect. I just want to ask why you guys are using such boring displays.
Hubert, you are right, character displays are a bit old today but I started my project without a screen at all since the goal was only to see live data on the smartphone using Torque by creating a sort of bluetooth ELM327 adapter.
When RPMS, vehicle speed, o2 sensor and coolant temperature were already working I decided to add a screen with a touchpad to be able to see live data also without connecting the phone (very usefull for SW development) and then the SD adapter to be able also to save the data directly on a microSD.
apollokid is offline   Reply With Quote
Old 06-04-2021, 09:38 AM   #36
hk 40
Board Member
 
hk 40's Avatar
 
Join Date: May 2011
Location: RTP, North Carolina
Default

Quote:
Originally Posted by apollokid View Post
Thumb up Bob, congratulations for the progresses
I paused my works after having rebuilt the prototype board, at the moment I'm still waiting for some schottky diodes from aliexpress and since holidays are coming I think I will restart works after them.
For the 3D picture of the board, also Kikad has this feature and I find it really great!


Hubert, you are right, character displays are a bit old today but I started my project without a screen at all since the goal was only to see live data on the smartphone using Torque by creating a sort of bluetooth ELM327 adapter.
When RPMS, vehicle speed, o2 sensor and coolant temperature were already working I decided to add a screen with a touchpad to be able to see live data also without connecting the phone (very useful for SW development) and then the SD adapter to be able also to save the data directly on a microSD.

No critiques just suggestions. You don't have to explain why you did things your way. What u are doing is really great and with your computing skills you can make the smart screen do all kinds of wonderful thing. The vacuum florescent displays are very bright with small pitch they can do smart serial and parallel DMA. You can section of different parts of the screen for different visualizations. Nailing the functionality down first was certainly priority and that makes sense. Here are a few screens that I know will integrate with Arduino MCUs. They are much cheaper than Noritakes but you lose some of the SMART functionality however they still have a small pitch and will look great. Thank you for responding to the suggestion Apollo! Once I get all the hardware figured out for the boost controller I may need your "c" computing skill as the basic port is high level and slower.. The knock spectrum analyzer may still require DSP. TI has a few chips Im looking at. Anders has created fairly detailed schematics. If I can find the mics output aft of the analog filters I may be able to tap in there and avoid Digital sound processing since I know that's already done in the Analog domain of the unit which appears to be mostly op amp filters and signal amplification.





Regards
Hubert

Last edited by hk 40; 06-04-2021 at 12:38 PM..
hk 40 is offline   Reply With Quote
Old 06-05-2021, 02:23 PM   #37
bobxyz
Board Member
 
bobxyz's Avatar
 
Join Date: Aug 2014
Location: Boulder CO
Default

The stuffed boards showed yesterday and they look nice! I'm really impressed - the design files were uploaded late a week ago Wednesday (5/26), and I have 10 fab'd and assembled boards in hand (6/4), from China, in just under 9 days. (click pics for full size)



So far, I've just applied power and all seems fine. I did find a couple minor booboos already (one of the Arduino mouting holes is 0.1" off, and one of the DB-15 mounting pins hits the Arduino power jack), but that's what prototypes are for. I'll update this thread once I have time to wire up the board to my benchtop LH/EZK setup and do some basic checks.
bobxyz is offline   Reply With Quote
Old 06-05-2021, 03:27 PM   #38
hk 40
Board Member
 
hk 40's Avatar
 
Join Date: May 2011
Location: RTP, North Carolina
Default

NICE!!!!

Regards
Hubert
hk 40 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:53 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.