Roseandthistle
New Member
Hi all.
I'm working on a project that is 90% complete. It's the last 10% that's giving me grey hair. I'll try and lay this project out first then ask the questions I need help with.
Project: Sequential battery charger. I've got a 6vdc / 12vdc with charge and float. Charge is connected to PINA.2 of the picaxe with an opto-isolator.(works)
12 relays, transistor driven, diode protected. (works)
4x20 lcd, 1 ADC input, ACS 712 Hall effect current sensor, 28X2 Picaxe
Scope: The program I've got so far, cycles through the relays one at a time with a pause in between. If PINA.2 goes high (battery is charging) then an interrupt occurs. When this condition clears then the program continues on. Until, the next battery needs charged.
Problem: In searching the posts and internet, I found that most Allegro Microchip's , Hall Effect chips are 6 months from production. I did find an ACS 712 breakout board at Sparkfun.com. The spec sheet says that with no current going thru, an output will be 2.5vdc. I've tried it, it's correct. The spec sheet also states that the chip is rated for 5 Amps. I only need 500 mAmps. http://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
Now I've got an input to adcsetup 0.Readadc10 0 ,SensADC
W1= SENSADC - REFADC * OFFSET / RESOL 'W0 - 512 * 98 / 20
serout A.1,BR,(254,151,".",#W1)
Questions: First of all, Am I thinking the math correctly?
2: Where do I put the READADC10 (sub routine) so it will update regardless of anything else going on.
3: Can I use SELECT CASE with READADC10 to make an lcd backlight turn off, or clear an interrupt, at a predetermined reading?
4: Bar graph. I would like to add a bargraph to line 4 of the lcd. Is there an easy way to do this? Starting out left (-)and increasing to the right as the mAmps decrease.
Thanks in advance.
I'm working on a project that is 90% complete. It's the last 10% that's giving me grey hair. I'll try and lay this project out first then ask the questions I need help with.
Project: Sequential battery charger. I've got a 6vdc / 12vdc with charge and float. Charge is connected to PINA.2 of the picaxe with an opto-isolator.(works)
12 relays, transistor driven, diode protected. (works)
4x20 lcd, 1 ADC input, ACS 712 Hall effect current sensor, 28X2 Picaxe
Scope: The program I've got so far, cycles through the relays one at a time with a pause in between. If PINA.2 goes high (battery is charging) then an interrupt occurs. When this condition clears then the program continues on. Until, the next battery needs charged.
Problem: In searching the posts and internet, I found that most Allegro Microchip's , Hall Effect chips are 6 months from production. I did find an ACS 712 breakout board at Sparkfun.com. The spec sheet says that with no current going thru, an output will be 2.5vdc. I've tried it, it's correct. The spec sheet also states that the chip is rated for 5 Amps. I only need 500 mAmps. http://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
Now I've got an input to adcsetup 0.Readadc10 0 ,SensADC
W1= SENSADC - REFADC * OFFSET / RESOL 'W0 - 512 * 98 / 20
serout A.1,BR,(254,151,".",#W1)
Questions: First of all, Am I thinking the math correctly?
2: Where do I put the READADC10 (sub routine) so it will update regardless of anything else going on.
3: Can I use SELECT CASE with READADC10 to make an lcd backlight turn off, or clear an interrupt, at a predetermined reading?
4: Bar graph. I would like to add a bargraph to line 4 of the lcd. Is there an easy way to do this? Starting out left (-)and increasing to the right as the mAmps decrease.
Thanks in advance.
Code:
#PICAXE 28X2
'#COM 4
#SLOT NUMBER 0
#FREQ M4
'OUTPUTS:
'C4 RELAY1
'C5 RELAY2
'C6 RELAY3
'C7 RELAY4
'B0 RELAY5
'B1 RELAY6
'B2 RELAY7
'B3 RELAY8
'B4 RELAY9
'B5 RELAY10
'B6 RELAY11
'B7 RELAY12
'A1 LCD
'C0 MANUAL MODE 6VDC
'C1 6VDC MODE
'C2 12VDC MODE
'C3 MANUAL MODE 12VDC
'INPUTS:
'A0 OP AMP ADC
'A3 CHARGE
'A2 FLOAT CHG
'SET PINS:
let dirsA = %11110010 'SET PINS AS OUTPUTS
let pinsA = %00001111 'SET AS OFF, A0,A2 INPUT
let dirsB = %11111111 'SET PINS AS OUTPUTS
let pinsB = %00000000 'SET AS OFF
let dirsC = %11110110 'SET PINS AS OUTPUTS
let pinsC = %00000000 'SET AS ON, C1, C2 OUTPUTS
let adcsetup = 0
'SET CONSTANTS/VARIABLES
SYMBOL BR = T9600
SYMBOL TIMEOFF = 1000
SYMBOL SENSADC = W0
SYMBOL REFADC = 512
SYMBOL OFFSET = 98
SYMBOL RESOL = 20
pause 1000
'LCD:
INIT:
serout A.1,BR,(254,0X7C,140)'Backlight brightness control 128off,140 40%,150 73%,157 100%
serout A.1,BR,(254,0X01) 'Clear and wait
pause 1000
MAINLCD:
serout A.1,BR,(254,128," SEQUENTIAL")
serout A.1,BR,(254,192," BATTERY CHARGER")
serout A.1,BR,(254,148," MODEL 1200")
pause 1000
serout A.1,BR,(254,0X01) 'Clear and wait
pause 1000
serout A.1,BR,(254,128,"Battery Number")
serout A.1,BR,(254,188,"Is now charging at")
serout A.1,BR,(254,160,"mAMPS")
BARGRAPH:
MAIN:
HIGH C.4 serout A.1,BR,(254,145," 1")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW C.4
HIGH C.5 serout A.1,BR,(254,145," 2")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW C.5
HIGH C.6 serout A.1,BR,(254,145," 3")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW C.6
HIGH C.7 serout A.1,BR,(254,145," 4")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW C.7
HIGH B.0 serout A.1,BR,(254,145," 5")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.0
HIGH B.1 serout A.1,BR,(254,145," 6")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.1
HIGH B.2 serout A.1,BR,(254,145," 7")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.2
HIGH B.3 serout A.1,BR,(254,145," 8")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.3
HIGH B.4 serout A.1,BR,(254,145," 9")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.4
HIGH B.5 serout A.1,BR,(254,145,"10")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.5
HIGH B.6 serout A.1,BR,(254,145,"11")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.6
HIGH B.7 serout A.1,BR,(254,145,"12")
GOSUB INTERRUPT
PAUSE TIMEOFF
LOW B.7
GOTO MAIN
'SUBROUTINES
INTERRUPT:
READADC10 0,SensADC
W1= SENSADC - REFADC * OFFSET / RESOL 'W0 - 512 * 98 / 20
serout A.1,BR,(254,151,".",#W1)
pause 1000
IF PINA.3 = 1 THEN INTERRUPT 'IF A BATTERY IS DETECTED THEN
PAUSE 2000 'STOP UNTIL BATTERY
SETINT %00001000, %00000000, A'IS CHARGED THEN CONTINUE
RETURN