Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:52 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : Piclog voltage calculation-readadc10?

Author Message
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 12:59pm 28 Aug 2014
Copy link to clipboard 
Print this post

Hi,

Looking at Glenn's code:

readadc10 0,w0
w0=w0 min 100
w0=w0 max 355
Volt=w0-100

and similar for the Amps. What I cannot see is the following:

readadc10 would read in the voltage into a cut-down 10-bit word with a resolution of 0 to 1023. However, this 10-bit resolution is not being used or at least I cannot see it.

I can see that for a 12V system anything less than 10V is of little interest and will be logged as 10V.

35.5V for a 12V system intrigues me as the battery would clamp the voltage to a max. of 14.7 or so when charging terminates but in your Piclog case the MOSFETs switch off the charge to the battery once it is full and only the dummy load is connected. Is my reasoning correct??
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 01:12pm 28 Aug 2014
Copy link to clipboard 
Print this post

Hi Dom

I think you mean the Picaxe based charge controller, not the PicLog.

Dont forget the bottom line, Volt=w0-100. This gives us a voltage range of 0 to 25, not 10 to 35.

I think you can include that line if your using the charge controller on a 12v battery. Leave it out for a 24v battery.

Glenn
The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 01:26pm 28 Aug 2014
Copy link to clipboard 
Print this post

Thanks Glenn for prompt answer. If I ever get my mill going I will have to change your code to 36V as I was given a 36V UPS. What about this 10-bit resolution, could this be used to our advantage? Or is the Picaxe not accurate enough anyway?
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Gizmo

Admin Group

Joined: 05/06/2004
Location: Australia
Posts: 5078
Posted: 03:09pm 28 Aug 2014
Copy link to clipboard 
Print this post

The 10 bit resolution was used as a clever way to display volts and amps and calculate watts, remembering the PicAxe doesn't support floating point mathematics. You could change the code to work with higher voltages, up to you to work it out.

That charge controlled is getting a bit old now, and the code did push the limits. I even ran out of variables, so started using pokes and peeks to save temp values, which is messy. There are chips, like the MicroMite, that are about a thousand times more powerful, cheaper, and easier to program. With a little modification the original circuit could be adapted to use a Micromite.

But the old controller does work, I still have one running here, so its OK to use, but I wouldn't expect too much more out of it.

Glenn


The best time to plant a tree was twenty years ago, the second best time is right now.
JAQ
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 07:19pm 28 Aug 2014
Copy link to clipboard 
Print this post

Thanks Glenn. I have also noticed the power of the MicroMite by reading Silicon Chip's article on it. Your comment "0 = 10 Volts, 255 = 35.5 Volts" caused me to ask the question re 10 Volts. My 28X has a bit more variables to play with.
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 03:38am 29 Aug 2014
Copy link to clipboard 
Print this post

The later Picaxe chips have many more variabls than the early chips and far more functions to boot, but still retain the math problems.

There is no reason the picaxe can not do the job required and with the later chips much easier than the chip Glenn used.

Dom, i see you on the picaxe forum asking questions, so guess you are interested in working with picaxe, and there is more than one way to do a project, Glenn has give an example to a project, but even that can be refined to work better, its all a matter of what you want to do and the correct components to support the circuit to do it with.

Help is alway close should you ask for it.

Pete.
Sometimes it just works
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 08:06pm 29 Aug 2014
Copy link to clipboard 
Print this post

Here is my desperate attempt to get my unfinished 28X to work in my copy of Glenn's work:

36V system, assuming 3x10V to be measured as the minimum battery voltage, 3x14.7 or so as max., used 60V.

Assuming we have floating point, here are my ideas with a voltage divider of 2k and 27k:

volt = 30 x 2/(27 + 2) = 2.069V and 4.138 for a voltage in of 60. Appears as

volt = 2.069/5*1023 = 423 in the word variable after readadc10 and 847 for 60V. Reference voltage is 5V.

volt = volt min 423 'anything less than 423 becomes 423
volt = volt max 847 'larger than 60V becomes 847

volt = volt/2 'scale back as both numbers are still > 255

volt = volt-211 '0 now for 30V and 211 for 60V

Is this logic correct? Any suggestions for improvement?

dom



Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 10:28pm 29 Aug 2014
Copy link to clipboard 
Print this post

  Quote  volt = volt/2 'scale back as both numbers are still > 255


Im not sure why you would want to scale back???

I dont know Glens code, but as Volts are already above 255, as its required to use a "word variable" for readadc10 to start with, and a word variable can go up to 65535 before it will overflow (not 255) then i see no reason to scale back the volts.

Pete.
Sometimes it just works
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 10:05pm 30 Aug 2014
Copy link to clipboard 
Print this post

Pete,

Thanks for help, once again. I have always wondered why various members scale it back to a byte-sized number, I suspect now it is simply done for the debug command and no other reason. And I am easily confused; not when it comes to 2**8 - 1 or 2 ** 16 - 1, I used to teach this stuff. Perhaps it was also done for storage of voltage in byte form during logging. And for the integer maths it needs a lot of watching for overflow.

After debugging I can simply comment out the debug commands.

Another question: I have a "sea of holes" as a proto board. Lots of copper rings and holes less than a millimeter. Both long edges have long copper "strips", any idea what they are for?

My terminal blocks have pins of 1mm in diameter. Had to buy a 1mm drill to open up the holes in the Picaxe proto board, isn't electronics fun!
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 11:41pm 30 Aug 2014
Copy link to clipboard 
Print this post

Dom,

I have no idea to what board you have, as there is several 28x boards or even what version chip you have.
Is your chip a 28x2 chip or the much older 28x chip.

Is this the board you have ..........

http://www.picaxestore.com/index.php/en_gb/picaxe/project-bo ards/axe020.html

I really dont understand what it is you want to do with the project, and would seem you wish to use Glenns code with changes, but what code of Glenns you are using im unsure.

Even your code questions done make a lot of sense to me, i need a bigger picture of what it is you intend to do and perhaps a look at the code you are working with.

If you can post your full code to the forum, or if you prefer not than email me your code (i think my email is active in the forum contacts) or PM me with your code.

I dont mind helping, i just need to understand what the project is and how you want it to work, and where you are at with it.

Perhaps even send me a phone number and i can call you for a chat one evening to better understand what you want to do.

Pete.
Sometimes it just works
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 12:46pm 31 Aug 2014
Copy link to clipboard 
Print this post

Pete,

Thanks for reply. Much older 28X chip with an AXE022 proto board. Am taking it as a challenge to finish this mill controller with this outdated chip rather than buying a Minimite or similar with proper ADC, floating point, etc. My mill is half finished too.

Using Glenn's code and schematic I want to sense voltage, amps and RPM to switch a dump load on, most likely a hot water heater. More an intellectual exercise with lots of dreaming, so I do not want you to spend time on it, but your help is appreciated.

This AXE022 will then to talk to one or more boards, one Allegro board for Amps like Glenn's, one for counting the AC changes for RPM and a voltage divider for Volts.

I will send code fragments once I have my testing finished. I simply like to know more about electronics.

On my copper plated on one side, numbered and lettered on the other side "sea of holes", what can I use those 10mm long, 3mm wide copper strips for? Perhaps 5V supply points similar to the outside red/blue lines on the "stick-in" proto boards?
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Downwind

Guru

Joined: 09/09/2009
Location: Australia
Posts: 2333
Posted: 01:33am 01 Sep 2014
Copy link to clipboard 
Print this post

Dom,

I have never used a Picaxe Proto board in my life and Picaxe dont give a clear schematic of the board, so im of no help what your "Sea of holes" do or can be used for.

I personally think the 28x or 28x2 chip is one of the hardest to work with, as is most of the x2 range of chips , because they require a lot of config setup in code to do simple functions, where the M2 range chips simply work as commanded in code without the need for config setup.

From what you tell me you want to do a simple 08m2 chip or bigger would do that, and far easier to program code wise.

I have lost count of the various controller systems or data logging systems i have designed or built and never yet required a 28 pin chip.

My mill controller reads Volts, Amps, RPM, Windspeed, and also has overspeed braking where if the mill RPM goes above 450 RPM (selectable)it activates the brakes (dumpload), i call it a mill saver.

There is a dozen ways to skin a cat, and why i asked to see your code is it will allow me to help teach you how to tackle the problems you have.

Up to you, but i have done this project many times in many different ways with many people, and the code is a basic copy paste requirement for me now, but not for a 28x chip.

Should you want a PCB for a smaller M2 chip im happy to make you one as i have the artwork done for all my projects thus far, and changes are often quick and simple to do to fit a new project requirement.

You say you want to learn more in electronics, well sometimes you need to step back and do simple testing, and other times be guided from those who have done it before you.

I do respect your will to resolve issues on your own, but sometimes its better to ask and learn and move forward with knowledge, rather than fumble around in the dark and still not understand what solved the problem.

Pete.
Sometimes it just works
 
domwild
Guru

Joined: 16/12/2005
Location: Australia
Posts: 873
Posted: 12:19pm 01 Sep 2014
Copy link to clipboard 
Print this post

Thanks Pete. Should not have used this forum once again to ask simple questions, like "What are those copper strips for?" as Dr Google tells me on being asked: "How do you solder on proto boards?" that those lugs are for common Vcc ground connections and even shows pictures. No wonder WATSON can beat even the best quiz masters!

Thanks for offer of PCB but I better learn by making lots of mistakes first, however, as I have learned a lot from Glenn's code and only if you can spare the time, then pls email your voltage, amps, rpm and windspeed.

All I can show so far are code fragments, like the rpm code, which I could not find in Glenn's code, but will certainly show my complete and working code once I have it assembled.

Suggested RPM code:

count 1, 5000, rpm 'count pulses in 5 seconds
rpm = rpm/14 'one rev=14 pulses
rpm = rpm*12 '60 secs=RPM
debug rpm

domEdited by domwild 2014-09-03
Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up.

Winston Churchill
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024