Badcaps.net Forum
Go Back   Badcaps Forums > Troubleshooting Hardware & Devices and Electronics Theory > General Electronics Technical Discussion
Register FAQ Calendar Search Today's Posts Mark Forums Read

 
Thread Tools Display Modes
Old 07-17-2019, 09:42 AM   #41
budm
Badcaps Veteran
 
budm's Avatar
 
Join Date: Feb 2010
City & State: S.F. Bay area
My Country: USA
Line Voltage: 120V 60Hz
I'm a: Knowledge Seeker
Posts: 36,998
Default Re: Running a microcontroller in car - power supply aspects

I am curious as to why the OPTO LED's side are not running of the regulator in your circuit. It looks like you are using OPTO as level shifter.
__________________
Never stop learning
Basic LCD TV and Monitor troubleshooting guides.
http://www.badcaps.net/forum/showthr...956#post305956

Voltage Regulator (LDO) testing:
http://www.badcaps.net/forum/showthr...999#post300999

Inverter testing using old CFL:
http://www.badcaps.net/forum/showthr...er+testing+cfl

Tear down pictures : Hit the ">" Show Albums and stories" on the left side
http://s807.photobucket.com/user/budm/library/

TV Factory reset codes listing:
http://www.badcaps.net/forum/showthread.php?t=24809

Last edited by budm; 07-17-2019 at 09:44 AM..
budm is offline   Reply With Quote
Old 07-17-2019, 09:52 AM   #42
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Red face Re: Running a microcontroller in car - power supply aspects

Quote:
Originally Posted by budm View Post
I am curious as to why the OPTO LED's side are not running of the regulator in your circuit
This
Quote:
Originally Posted by budm View Post
It looks like you are using OPTO as level shifter.
It's mostly out of commodity and to keep the car's circuit as stock as possible. 12v is present at the switches already, so to run off 5v, I'd have to cut the incoming power wires from the car's system to the switches and wire in my 5v line there, which of course would work, but I just don't want to alter that part. It's not a pleasure working on the wires in that dash - very tight in there, with wires going everywhere, so it has to be as plug and play as possible: connect it up then get out of there as quickly as possible
__________________
Wattevah...
Dannyx is offline   Reply With Quote
Old 07-17-2019, 09:59 AM   #43
budm
Badcaps Veteran
 
budm's Avatar
 
Join Date: Feb 2010
City & State: S.F. Bay area
My Country: USA
Line Voltage: 120V 60Hz
I'm a: Knowledge Seeker
Posts: 36,998
Default Re: Running a microcontroller in car - power supply aspects

I see, trying to keep wiring as original.
budm is offline   Reply With Quote
Old 07-17-2019, 10:53 AM   #44
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Default Re: Running a microcontroller in car - power supply aspects

Quote:
Originally Posted by budm View Post
I see, trying to keep wiring as original.
Precisely.
Dannyx is offline   Reply With Quote
Old 07-18-2019, 01:39 AM   #45
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Lightbulb Re: Running a microcontroller in car - power supply aspects

Had another look over the schematic and made another change: the lock/unlock signals on the right now also have optoisolators (PC5 and PC6). This is actually how the circuit is currently set up on the breadboard, but I omitted those two for some reason. Trouble is, I can't add a protection diode there because those pins swing low/high when locking/unlocking. Basically those two wires I labeled there run from the ECU to the 4 actuators in the doors and 1 in the trunk and I need to somehow tap into them to trigger certain functions on the Arduino. It's a simple H-bridge inside the ECU that does this I THINK: when you lock the car, the LOCK pin gets 12v on it and the UNLOCK pin stays low. When you UNLOCK the car, the reverse happens: U/L pin gets 12v on it and the L pin stays LOW. I measured this to confirm. Adding a diode there would create a short, yet I still need to have some sort of protection there, since linear actuators create a ton of inductive kickback which overtime can kill those LEDs. A capacitor perhaps ?
Attached Images
File Type: jpg SwitchesModified.jpg (187.9 KB, 9 views)
Dannyx is offline   Reply With Quote
Old 07-18-2019, 09:33 AM   #46
budm
Badcaps Veteran
 
budm's Avatar
 
Join Date: Feb 2010
City & State: S.F. Bay area
My Country: USA
Line Voltage: 120V 60Hz
I'm a: Knowledge Seeker
Posts: 36,998
Default Re: Running a microcontroller in car - power supply aspects

Why would Low (Grounded) signal be problem? The MCU signals are ref. to GND. Am I missing something?
budm is offline   Reply With Quote
Old 07-18-2019, 09:53 AM   #47
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Default Re: Running a microcontroller in car - power supply aspects

Quote:
Originally Posted by budm View Post
Why would Low (Grounded) signal be problem? The MCU signals are ref. to GND. Am I missing something?
Actually you're right. I was thinking the pin would short out through the diode, because for some reason I mistakenly assumed the diode would go between the L and U/L pins themselves, which is not correct - it would go between EACH pin and GND, so when the pin is pulled high, the diode is reversed-biased and doesn't conduct and when it stays low, it's essentially GND, so no current flow either.

Another thing that confused me is the way those L/UL rails are laid out they look very similar to a split-rail supply, with GND being in the middle, L being let's say + and U/L being -, although it's nothing of the sorts, so that's another thing that threw me off, so you're right: diode across each of those LEDs and I should be good. Can't believe I screwed up on such a simple electronics circuit
Dannyx is offline   Reply With Quote
Old 07-19-2019, 12:19 AM   #48
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Lightbulb Re: Running a microcontroller in car - power supply aspects

Updated schematic. Added D6 and D7, plus a simple plot of the lock/unlock pins.
Attached Images
File Type: jpg SwitchesModified.jpg (194.4 KB, 12 views)
Dannyx is offline   Reply With Quote
Old 12-17-2019, 10:04 AM   #49
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Talking Re: Running a microcontroller in car - power supply aspects

Alright gents (and ladies, if there's any watching ), since I'm on my winter break and I have some spare time on my hands, I thought I'd go back on this project which should've been finished last year

Here's what I've been up to: as you guys suggested, I went with 2k resistors for the LEDs of the optocouplers instead of having the zener diode as well. I tested and it works, so I rolled with it.

Pullup resistors: you guys suggested using the internal pullups on the digital pins so I wouldn't have to use external ones, but I could not get this to work - either I'm doing something wrong (most likely, since we all know I'm a bit of noob at this stuff ), or simply changing the pinMode in the beginning is not enough and I have to tweak the rest of the code as well. What happens is I do pinMode(x, INPUT_PULLUP) and measuring with a multimeter shows the pin does indeed go high after pulling the 10k pullup resistor off the breadboard, but when I push the button and the optocoupler turns on and pulls that pin low, the action related to that button being pressed gets stuck on and runs continuously. If I understand correctly, it should work the same, with no other changes....

Current sensors: I played around with the "analogRead" and a current sensor and I think I got this one right: I used the serial monitor to read the values the pin was giving me at different voltage inputs, from 0 when fully grounded, all the way to 1024 (I think) when pulled all the way to 5v. The current sensor I got (which I can't remember for the life of me what model it is right now), outputs a value between 2.5v at 0A and 8v! at 30A! (if I remember the datasheet correctly). My car window motor draws precisely 15a when the motor is stalled, so to test this on the bench, I paralleled two 10w low-ish value resistors to drop their resistance even more, wired this setup in series with my current sensor and put the whole thing on my power supply. I began cranking the voltage and observing the values the sensor gave me at different currents. It's approximately 3.8v at 15A, so I took a note of the value the serial monitor was giving me and I'll use this to tell the program to stop the H-bridge when it detects this value consistently for 1-2 seconds to prevent false triggers from the inrush current...at least that's the theory...
Dannyx is offline   Reply With Quote
Old 12-17-2019, 08:05 PM   #50
redwire
Badcaps Veteran
 
Join Date: Dec 2010
City & State: Alberta
My Country: Canada
Posts: 1,643
Default Re: Running a microcontroller in car - power supply aspects

It looks pretty good so far
R5 1k is a bit low, I would use 10k for less heat. If ZD5 is a good size, you could get rid of D1/L1, they can be awkward. D1 could be smaller 1N4004, or just in series with power and no L1.
Arduino Atmega328 pull up resistors are about 36k ohm, PC817 transistor even really hot 90C has 1uA leakage current. So you should not be having problems with that, here is code I use for pusbutton only w/pullup:

Code:
//------  I / O   P i n   A s s i g n m e n t s  -----  U N O  ------------
#define battery_voltsPin A3  
#define PushButtonPin 6 
#define LowBatteryLampPin 5    
#define LEDPin 13   
//*************************************************************************
void setup() {
 
   digitalWrite(LEDPin,LOW) ;    // led off if low
   pinMode(LEDPin, OUTPUT);      // sets the digital pin as output
   //------------------------------------
   pinMode(battery_voltsPin, INPUT);	// sets the analog pin as input, no pullup 
   analogReference(INTERNAL);	// A/D Vref is 1.1V full-scale
   //------------------------------------
   digitalWrite(LowBatteryLampPin,OFF);	// Low Fuel Lamp off
   pinMode(LowBatteryLampPin, OUTPUT);		// sets the digital pin as output
   //------------------------------------
   pinMode(PushButtonPin, INPUT_PULLUP);     // sets the digital pin as input w/pullup
   //------------------------------------
} 
//*************************************************************************
redwire is offline   Reply With Quote
Old 12-18-2019, 03:32 AM   #51
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Default Re: Running a microcontroller in car - power supply aspects

Yeah, I did this too: pinMode(PushButtonPin, INPUT_PULLUP); but got the unwanted result of the output being stuck on all the time after the first push, as if the button was held down...does this work on the ProMini as well ? It should, after all, the microcontroller's the same on all of them, or very close....
Dannyx is offline   Reply With Quote
Old 12-18-2019, 02:31 PM   #52
stj
Great Sage 齊天大聖
 
stj's Avatar
 
Join Date: Dec 2009
City & State: Europe
My Country: some shithole run by Israeli agents
I'm a: Professional Tech
Posts: 22,168
Default Re: Running a microcontroller in car - power supply aspects

all 328 boards are the same - just more or less psu and programming crap on them.

you may want to see if the opto's are leaky by probing or scoping the outputs during testing.
stj is offline   Reply With Quote
Old 12-18-2019, 02:38 PM   #53
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Default Re: Running a microcontroller in car - power supply aspects

Could be down to the optocouplers somehow, since it doesn't turn on right away - it takes one trigger to get stuck, so I imagine the optocoupler turns on, pulls the pin low, but then it doesn't go back high again for some reason....
Dannyx is offline   Reply With Quote
Old 12-18-2019, 09:53 PM   #54
redwire
Badcaps Veteran
 
Join Date: Dec 2010
City & State: Alberta
My Country: Canada
Posts: 1,643
Default Re: Running a microcontroller in car - power supply aspects

It's not your hardware, I think. There must be other code using the same I/O pins as an output pin. I would look at the software more. I've never seen a digitalRead() work once and then stuck.
Unless the opto capacitor makes the rise time slow and not a Schmitt trigger input, or they are analog input pins.

The motor control should have a timeout of say 10 seconds to not cook the motor, in addition to the monitoring motor current and the switches. Chevy and Toyota had problems with recalls after people left a window cracked open and rain got in the switches and the motor stayed on.
redwire is offline   Reply With Quote
Old 12-19-2019, 03:27 AM   #55
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Thumbs up Re: Running a microcontroller in car - power supply aspects

Quote:
Originally Posted by redwire View Post
The motor control should have a timeout of say 10 seconds to not cook the motor, in addition to the monitoring motor current and the switches. Chevy and Toyota had problems with recalls after people left a window cracked open and rain got in the switches and the motor stayed on.
I have that. No matter what happens, the motor cuts out after 15s if something goes wrong and it doesn't stop for some reason. My switches are on the dash under the headunit, so water can't possibly get there, but still.

As for the code, I probably missed something. I might try it again....maybe there's more to it than just replacing INPUT with INPUT_PULLUP. When I switched back to INPUT and added my resistor again, it worked perfectly once again, so I don't know, maybe I'm doing something wrong....I'd show you the code, but it's a mess, so I'd rather not

I also happened to come across the perfect connector for the job: these things which I didn't even know could exist can carry both a high current input and some control signals, so they're perfect, albeit a bit pricey.

Last edited by Dannyx; 12-19-2019 at 04:30 AM..
Dannyx is offline   Reply With Quote
Old 02-19-2020, 10:58 AM   #56
Dannyx
CertifiedAxhole
 
Dannyx's Avatar
 
Join Date: Aug 2016
City & State: Constanta
My Country: Romania
Line Voltage: 230VAC 50Hz
I'm a: Hardcore Geek
Posts: 2,743
Red face Re: Running a microcontroller in car - power supply aspects

Still on this VERY slow project, just in case someone is still watching this thread and would be kind enough to reply back, I started laying it down on a piece of veroboard PCB to hopefully get one step closer to the final version. I now started looking at motor control, since it's equally important for this purpose: I initially wanted to go with THIS thing, but then I read about it more carefully and amongst other things I learned is that apparently you can't just hit it with a steady DC voltage on the control pins and let it run continuously - there has to be a switching PWM wave on the input pins there, with a duty cycle of up to 98%. Read the last post HERE.

I also have to be careful how I power it, since you can fry the microcontroller if you're not careful, since the power input for the motor itself is also tied to the V+ header pin which you'd assume is separate and should be used to power the low-voltage control part, but it's not, so you can easily send 12v into the I/O pins of your micro Same for the EN pins. Good thing I read that up HERE !

I also have THIS one in my shopping cart, since it's slightly cheaper. I'd need to provide my own heatsink though. It also handles less current and this is where it can get a bit ambiguous, since the first one doesn't precisely mention the current - it just says 0-30A, so I can only assume that's PEAK current and by no means continuous ! The "bare" one gives 10A as the continuous current and 30A as peak, though those values are probably "optimistic" ones and they're lower in reality. I actually measured the current draw on my car window: it's around 5-7A when the motor is running freely (depending on the temperature and how much crud is on the rubbers) and around 15A when the window reaches the end of travel and the motor stalls, so either of them should handle it if properly cooled (which might actually be a problem in the summer ! !). If those specs are anything to go by, the cheaper one can be driven up to 99% duty cycle, though I'm sure that's borderline irrelevant, so....yeah....not sure what to go with :|

Last edited by Dannyx; 02-19-2020 at 11:01 AM..
Dannyx 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 Off

Forum Jump



Badcaps.net Technical Forums 2003 - 2020
Powered by vBulletin ®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
All times are GMT -6. The time now is 09:45 AM.
Did you find this forum helpful?