Okay, so this might be a bit long. I've created a solar charge controller based on Julian Illet's PWM5 Charge Controller. Now my goal is to make a battery re-conditioner. Problem is, I really don't know much about programming overall. I used Julian's Assembly language code and a PIC12F683 Micro for the controller since it is vastly more power efficient then anything ATMega related. But for a recondition style device, power consumption isn't really a problem since instead of a solar panel, it'll be powered by the mains. That said, I think the charge controllers circuitry would work fine by just altering it's charging scheme, no point in reinventing the wheel again.
Here is the basics of how the charge controller works. It has a 5V regulator that's suitable for 30 volt input that powers the micro. The micro reads the voltage of the battery from an 80K-20K potential divider. From this voltage, it determines if it needs to increase the PWM though three transistors to an N-Channel MOSFET which is the only component exposed to high current since it just switches in and out the positive voltage from the panel. The ground is shared in this design. It uses a charge pump to create the ~20 volts necessary to drive the MOSFET. There is also a large power diode before the MOSFET to prevent backflow from the battery into the panel and to prevent shorts through the body diode of the MOSFET from the battery.
So, the goal here is to randomly allocate the PWM duty cycle as well as the length of time it uses this randomized duty cycle. So effectively I need to generate two random numbers. One will be between 1 to 3 seconds. This will be the amount of time it uses the randomized duty cycle before generating a new random number. Then the second will be the randomized duty cycle itself. Also to prevent overcharging, it needs a delay of one second and then a read of the battery voltage. If the battery reaches 14 volts (which I can do in math) then it goes into a loop where it waits for the voltage to fall again before restarting. Also, if there is a way to vary the frequency of the PWM pin as well, that would be fantastic. On my layout. Pin 9 is the PWM and A0 is the analog read for the potential divider. I already have the code, with some help, to run the charge pump.
So ideally the micro would randomly decided to use PWM with a 67% duty cycle on Pin 9 at 564 khz for 2.16 seconds. Pause a second, read the battery voltage once it's rested, and then decide to either pulse again at three more randomly allocated numbers, or pause for say ten minutes before checking voltage again and proceeding from there.
I've got a power supply capable of ten amps (which the MOSFET with a heatsink is able to handle easily, I think with proper cooling it's rated for like 35 amps or some absurd number like that).
Any help is appreciated. While I understand the very basics of coding (Like, I know what the Setup and Loop commands do), I am a complete novice at programming anything outside of some old BASIC stuff. I'm more of the hardware type but I am slowly learning.
I’m not expecting a code writing service. I don’t know what functions generate random numbers within a set range. I already have code to allow an Uno to run my charge controller which is all of about 20 lines and took me hours to bumble my way through. I was just hoping for someone let me know the kind of function I should use that I can plug into the existing program I have but I guess I didn’t phrase my question well.
link9454:
I’m not expecting a code writing service. I don’t know what functions generate random numbers within a set range. I already have code to allow an Uno to run my charge controller which is all of about 20 lines and took me hours to bumble my way through. I was just hoping for someone let me know the kind of function I should use that I can plug into the existing program I have but I guess I didn’t phrase my question well.
If Google works in your area, you should not even have to ask. I found a bunch of informative responses when I asked "arduino random number"
Paul_KD7HB:
If Google works in your area, you should not even have to ask. I found a bunch of informative responses when I asked "arduino random number"
Paul
Well, excuse me for hoping someone would be helpful. If a newbie at work asked for help with some job responsibility, I hope you'd do more then say "just go google it."
Clearly I've asked the wrong group of people who I expected to share a common interest and be willing to help someone new.
Help is what we give, but we also try and match the effort you have made. From what I can see we have more than matched the effort you have put in.
For information about the random function go into the Arduino IDE, then the help menu and then select Reference. Up pops a page of lots of Arduino code including how to use the random function.
I used Julian's Assembly language code and a PIC12F683 Micro for the controller since it is vastly more power efficient then anything ATMega related.
Well apart from being absolute rubbish posting it on an Arduino forum is not going to win you too many friends. Given the fact you freely admit "I really don't know much about programming overall." How can you even think you can make such a statement?
Please read this:- How to use this forum It tells you about how to ask a question here.
link9454:
Well, excuse me for hoping someone would be helpful.
The post was extremely helpful. The first hit using the provided phrase has the exact information you need. The only way @Paul_KD7HB could have been more helpful is if they had traveled to your location and navigated your browser for you.
And, if Google is not your cup of tea, the first hit in duckduckgo is to the same webpage.
This will also be helpful: "not very sexy way to seed random".
Grumpy_Mike:
Well apart from being absolute rubbish...
That caught my eye as well. Opinions withheld to shield the newbie.
link9454:
Well, excuse me for hoping someone would be helpful. If a newbie at work asked for help with some job responsibility, I hope you'd do more then say "just go google it."
Clearly I've asked the wrong group of people who I expected to share a common interest and be willing to help someone new.
Yes, you are right. I would not have told that person to "just go Google it". I would have asked them 'what have you tried'? But in this case, that did not seem appropriate.