New User Get $30 User Coupons https://jlcpcb.com/CYT
Other Users Get SMT Coupons via Contacting JLCPCB Facebook
Driving the CP line can be done with opto-isolators.
Subscribed to my 2nd channel? Watch all my 3 minute videos on Julian's Shorts: https://www.youtube.com/channel/UCeewzdnwcY5Q6gcbnZKIY8g
Interested in my new garden workshop? Follow the entire build on Julian's Shednanigans:
https://www.youtube.com/channel/UCXfDjPehpC7B7lW2JFxeS4w
Join me on Odysee/LBRY: https://lbry.tv/$/invite/ @julian256:d
Octopus Energy referral link: share.octopus.energy/aqua-birch-918
(We each get £50)
#EasyEVSE
#ElectronicsCreators
Other Users Get SMT Coupons via Contacting JLCPCB Facebook
Driving the CP line can be done with opto-isolators.
Subscribed to my 2nd channel? Watch all my 3 minute videos on Julian's Shorts: https://www.youtube.com/channel/UCeewzdnwcY5Q6gcbnZKIY8g
Interested in my new garden workshop? Follow the entire build on Julian's Shednanigans:
https://www.youtube.com/channel/UCXfDjPehpC7B7lW2JFxeS4w
Join me on Odysee/LBRY: https://lbry.tv/$/invite/ @julian256:d
Octopus Energy referral link: share.octopus.energy/aqua-birch-918
(We each get £50)
#EasyEVSE
#ElectronicsCreators
Good morning, all this arduino is producing a one kilohertz square wave, which i can vary the pulse width of with this potentiometer. Now the amplitude is 5 volts. In fact, it's a bit less. This says that it's 4.65, this point down here, is ground, as indicated by the yellow marker and the top of this we'll call it 5 volts.
This is the voltage swing of the digital output of the arduino. Now, in order to instruct an electric car to uh start charging, we have to send a one kilohertz square wave, but not with a 5 volt amplitude. We actually need 24 volt amplitude and it has to go down to -12 volts and up to plus 12 volts relative to a ground connection. There's a ground connection on here now to translate this 5 volt square wave output to the plus and minus 12 volt square wave.
It's the same frequency, one kilohertz um. I need some sort of driver, so i'm thinking of using one based on two opto isolators, dual complementary up to isolators. So at one instant, one of them pulls the signal high to plus 12 volts and then for the other half cycle. The other opto isolator pulls the signal low to minus 12 volts.
Now. This is a circuit board that i made some years ago for driving the gate of a mosfet, and i was thinking of trying to use this, but i don't think it's going to work, because i need to make substantial changes to the way this. What i called decoy dual complementary opto isolator circuit works, i'll draw a sketch, so my original decoy circuit uh works like this. It has an upper opto isolator.
That's the opto transistor i'll draw some uh arrows going into it to indicate that these don't have a base. As such, they work by just having light sent into them. Um works like this by having the two optile isolators connected, like that. I think the top here was connected to five volts on this original circuit and the bottom here: zero volts.
Now i'm going to connect the top of this upper transistor. These are npn, incidentally, so the emitters are here, um the top of this to plus 12 volts. So let's put that in plus 12 volts and the bottom emitter will connect to minus 12 volts. So this is the output now on the input we've got leds so i'll mark those in like so and another one here, and the original decoy circuit had additional leds another one up here which i'll draw in and the idea of these additional leds.
Now these were either red or green leds. These leds here are integral to the opto isolator, so they're in fact infrared the addition of the forward voltage of the red. Let's call it a red led, the infrared led, another infrared led and another red led meant that with five volts across these four leds, they didn't actually light up. You did see a tiny, faint glow, but not bright enough to actually turn on these transistors.
So, with no drive to this input circuit, the two transistors were off and that's a good thing if you want to avoid the two transistors being on, because if all of these leds did light up say you raised this voltage from five volts up to. I know seven or eight volts, then these all leds would all turn on both these transistors would turn on and you'd, be shunting current from this positive supply, all the way down through the two transistors to what was originally zero volts, but will now be -12, and We don't really want these two transistors turning on at the same time and shorting out the 24 volt supply. Here now when driving the cp line of an electric car, you actually want a 1k resistor between the low impedance output of this driver and cp. So, let's mark this cp, i thought what would happen if i put the 1k resistor both here and here so when the top transistor turns on we're driving cp up to 12 volts through 1k, let's mark them in so we'll have 1k there and 1k. There. 1K. 1K. That means i can do away with this resistor, and now we don't have the problem that if these two opto isolators are turned on at the same time, we turn both these transistors on and put a very large current through those transistors.
Now we've got 1k resistor. In fact, we've got 2k resistance, 24 volts, so the current will be. I cause v over r. Isn't it so 24? Over 2 000 is 24 milliamps.
Now can an opto isolator transistor take a continuous current of 24 milliamps. We can check that, and that means that now we don't need this led and we don't need this led because it's actually perfectly acceptable. We'd need a resistor, so i'll put a resistor in here and another resistor here, um quite a low value, because we're going to be driving these leds from 5 volts we're going to be driving them from this 5 volt output from the arduino uh in the middle. Here so out from the arduino pulls this line low to turn this led on and then pulls this line high, which will turn this led on.
So these resistors could be something like 470, something like that might even go lower than that could go down to say 220 ohms. But when the arduino is first booted up the output won't be an output, it will be an input because that's the state that microcontrollers tend to set their. I o pins to before they've started to run firmware now. That means that briefly, current will flow through both these leds.
This is five volts up here, because this is arduino side. This is zero volts here. Both these leds will light up. Both these transistors will turn on briefly until the microcontroller starts executing code to convert this output to an output, and so briefly, there will be 24 milliamps flowing through both of these opto transistors.
If the opto transistors are happy with 24 milliamps, that's the circuit i want to end up with, and that is substantially different from what's on this little printed circuit board. So i think i'm going to have to build this separately to this, because i need to remove these two leds. Well, that's the two leds that you can see there little surface mount ones. I need to break this connection here, which is a little track. I don't think you can see it between the outputs of these two optos and insert a couple of 1k resistors. So no can't really use that board probably make this up on vera board initially just to test it. But that's the circuit, i'm thinking of using to turn the five volt square wave, one kilohertz coming out of the arduino into a plus 2012 and swinging to -12 output. Through these two 1k resistors, only one of them will will be used at any one time.
So it'll look like 1k and route that out to cp, which is an input on the vehicle so using the commonal garden pc817 opto isolator. We want the maximum current that the thing can withstand so absolute maximum ratings forward. Current 50 milliamps - and i said that um this brief period before the microcontroller starts running, we'll be putting 24 milliamps through each of these two opto transistors. So that's fine.
In fact, it says here you can have a peak forward current of one amp, although there is a note there and the note says not for very long less than or equal to 100 microseconds and in fact, that's the sort of time period that it would take. Possibly a millisecond, maybe for the um arduino to boot. Up there are occasions where this doesn't boot up very quickly, where it's checking something i think so you really do want this to be within the um. The standard continuous forward current rating of the opto isolator 50 milliamps, is fine.
Now these boards, i made for driving the gate of a mosfet, and i built these for doing experiments with buck and boost circuitry um, which was driving these optos at about 15 kilohertz any faster and they just really weren't quick enough to produce pure square wave outputs. But this circuit is going to be running at one kilohertz. That's the frequency that we've got on the scope, so optos are perfectly fine from a timing point of view uh for this application driving this cp line with a one kilohertz, albeit a large amplitude one kilohertz signal plus 12 to minus 12 they'll, be fast enough. Now for driving the cp line of my evse, my electric vehicle supply equipment, we can call it an ev charger um.
I want to limit the range of travel of the pulse width from 10 to the minimum, because 10 represents uh the car charging at 6, amps mains voltage, so 240 volts and a maximum of 50 percent, which would be 30 amps from a main supply. That's 7! Kilowatts now in my situation, i'm going to have to limit it further than that, because my house fuse is not 100 amps, it's only 60 amps. So i really don't want to um well and also the solar panels on the roof of my house only produce at their maximum 3.6 kilowatts. So i'm going to limit my system for those two reasons to 3.6 kilowatts, which i think is about 16 amps.
So you can see that i'm not going to be taking it much above 25 for the maximum current 16 amps. So in fact, i'm only going to be varying it between about 10 and 25. It's not that much of a range of movement, but that's the limitation that my home fuse and my solar array impose on my particular charging system. So here in the code that i wrote in in the last video um, i want to constrain the value that i write out to digital pin 3. So i'm going to put in here constrain and i want to have the values. Uh pot is my input value, but i want a lower level of about 10 percent. Now, 10 percent of now someone said actually that f9 was a better value than f8 to give an accurate one kilohertz. So i'll take that advice change that to f9 f8.
I think is 248 decimal, so we don't want this value going any lower than about 25. That's 10 percent and 25 in hexadecimal. I think, is 19. So we'll do a 0 x 19 and then the upper value will be about 25, which would be about hex decimal 40..
Wouldn't it so 0x 40., so constrain uh. I mean another bracket. There weren't sorry yeah constrain the value of pot between 19 hex decimal and 40 hexadecimal. That should do so.
Let's compile upload that and just see whether that works and that's resulted in this. So i'm constrained at the bottom end of the pop movement. Nothing much happens, then we get the range from 10 percent up to 25 percent and then there's a lot of movement at the top of the pot travel. You can see me turning it there and nothing happens on the scope, because we're constrained to that top value of about 40 hex, which should be a quarter or 25 percent and, in fact, um just to make this pot a little bit more sensitive.
I might uh divide the value coming from this part rather than divide by four, which i did originally to take a ten bit number down to an eight bit number. I think i'm going to divide it by eight just to give a better range of travel i'll. Just do that now right! Well, that's better! Um! If i turn this part there's a little bit of nothing at the bottom, then we go up to the 25 and then there's quite a lot of nothing still at the top. I could probably divide that by 16, but it's irrelevant really, because i'm not going to be using a pot to vary the pulse width, i'm actually going to be using a radio receiver which takes its data from a radio transmitter on my solar power system so that The car charges using what's available from the rooftop solar panels, but uh that can strain just make sure.
If i make errors in some other part of the software, they don't get sent out to the pwm and there the car then pulls way more current than my electrical system can handle and blows one of the breakers. We don't want that happening so that constrain will just limit it to that range of values, so that's kind of it. I need to build this circuit now i'll, probably build it on a bit of vero board um and somehow connect all this stuff together. I might screw this all down onto a plank of wood and then have another attempting to charge the car, but instead of using this um cmos clock with a crystal here, which is how i generated the 10 mark space ratio, one kilohertz square wave previously, i'm gon Na use the arduino - and i do want to be able to select a small range because i'll be doing the same thing. Charging the car from the big power bank, which can provide two kilowatts. So i'm really only going to be having a tiny amount of movement on the pulse width of this to go from six amps, which is the lowest current to. I think i can get away with eight amps from that big power bank. So a tiny amount of change of um pulse width and then we can see whether that's represented on the screen of the power bank, but i'll get building this.
That's it for this video, so cheerio.
You could replace the constrain and the analogue divisor with the map function. But of course you're not using the pot in the end. Nice use of the optos.