Cycling Champion generator control module useing BS2 detect 12v start\stop gen. batt. chargers

15681011

Comments

  • DEBUG says with no wire from battery bank "volt 1" is" 11.96 " "volt 2" is " 11.98" "OFF"
    next column "volt 1" is "10.63" "ON"
  • Are the 219's getting a false reading from the BS2????

    Why "10.63" if not connected to battery bank.???

    It is next to computer now.
  • kwinn wrote: »
    " 15 0000 OFF 32.57" Are you sure I only need 1 wire coming from the batterys to give the 219 sensor a voltage reading?

    You need 2 wires. The battery+ to Vin+ and the battery- to a ground. The battery-, Basic Stamp ground, and INA219 ground all need to be connected together at some point as close as possible to the Basic Stamp.

    Ok when I had it wired this way it also powered the Bs2.

  • kwinn wrote: »
    You are getting a voltage reading of 32.57, but that is high, probably because I forgot to remove a line of code I was using for debugging. Instead of digging out a 12V supply to hook up I used the 5V and multiplied it by 3 so I ended up with about 14.5 and 8.0 volts. Delete or comment out the line marked "FOR DEBUGGING ONLY".
    Vavg:
      reps = 8
      VbusM = 0
      DO WHILE (reps > 0)
        TOGGLE BICLED1
        TOGGLE BICLED2
        GOSUB INA219ReadBus    'get voltage from selected INA
        VbusM = VbusM + (i2cData >> 3)
        reps = reps -1
      LOOP
        VbusM = VbusM * 3  'FOR DEBUGGING ONLY
      RETURN
    

    Sorry about that.
    Thats ok your doing great we will get it to work. We just have to keep trying.

    I could not find this in your amended code. I dont think this is in the most recent code that I am using.

    I will change the ground input wiring. It might back feed voltage to the BS2 through the 219.

    Sunday is fine Thank you for all your genius efforts with my project.


  • Very fortunate to have you, Kwinn ,coding for me. Thanks I don't know what I would do without your help. I will try to talk to you late Sunday or on Monday.
  • kwinnkwinn Posts: 7,512
    kwinn wrote: »
    " 15 0000 OFF 32.57" Are you sure I only need 1 wire coming from the batterys to give the 219 sensor a voltage reading?

    You need 2 wires. The battery+ to Vin+ and the battery- to a ground. The battery-, Basic Stamp ground, and INA219 ground all need to be connected together at some point as close as possible to the Basic Stamp.

    Ok when I had it wired this way it also powered the Bs2.

    Just to be sure we're on the same page, by battery+ to Vin+ I meant the INA board Vin+.

    You might be able to power the BS2 from that as well, but that might be pushing the power dissipation of the linear regulator on the BS2 close to the limit.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • When I plug in the sensor wires (INA219) first.........BS2 powers up...... then I plugged in the wall adapter source.
  • With the switch on the front "off" it powers everything on
  • kwinnkwinn Posts: 7,512
    All I can suggest atm is to check your wiring very carefully and use a meter to compare the Vin+ voltage to what the debug screen says.

    It's good night time for me.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Ok so I have wired in both battery banks.
    The negative wires are connected into the ground circuit NOT the blue headers (Vin -) on the 219's.

    I have ran some preliminary tests.

    I reinstalled the box...........1 connected the battery to generator switch wires (a mono 3.5mm male audio jack)

    2 connected the ac/dc wall adapter to dc/ac inverter powered outlet.
    this blew the .75amp fuse because the 6 pin header has a "Vin -" that I connected into the ground circuit on the BS2

    apparently the 6 pin headers as well, on the 219's DON'T need to have "Vin-" connected to ground.
    I pulled out those two wires from the bread boards [cursing loudly] and reinstalled another glass fuse.
    The 9,000 powered up without the battery bank leads after I pushed the red switch.

    3 now I connected the "live" "13.5volt and 13.4 volt" battery banks to the 9,000

    4. The 9,000 began its conditional address {the digital displays began to count generator started running}
  • I started this test at 6:15 pm (6:17pm grunting with octave change in engine sound) powering up the 4 and 3 stage battery chargers. Started at 13.5 and 13.4 volts input.

    Form there it counted and counted. The 9,000 had started the generator.

    I looked at the 9,000 at 8:20pm. The BS2 had shut down," The 9000's", two digital timer relays for some unknown programmed variable. Both digital timers were "OFF" . Green LED And Bi Led still actively blinking. Generator was still running. Battery banks were at 13.8volts.

    I manually shut down the generator by holding down the lit up Onan switch.
    I went back in my house...............The BS2 powered 9,000 started the generator up by itself at 13.7volts.


  • When the 9,000 initiated the autonomous control of the generator the digital displays on the header above my dash were
    reading "13.5, 13.4,13.5,13.6"

    The battery chargers and tiny 12 volt socket [fan above the generator relay] were still plugged into the generator.

    I went back outside and initiated a manual shut down because after dark the generator makes "too much noise"

    I plugged "the charger circuit" into a 30amp land line.

    I left the 9,000 in an active sequence with digital displays on "0050" and something like "8765 and counting down"
    Generator is off. Onan battery to generator light is lit.
  • I believe the BS2's programming failed to shut down the generator because the GERI timer {T2} needs to momentarily close the remote "STOP" button circuit for longer than "06seconds"

    Theory is : if the button is held down longer the wireless transmission to the generator will be received thus shutting it down after the GERI "T1"sequence of 9,000 seconds is counted down.
  • The BS2 has no hardware to shut down the generator. The EAZY timer when powered on from B2 relay has a "n.c." and com to battery power and generator.

    The GERI has the "STOP" remote button for 6 seconds after 9,000 seconds.

    if the EAZY and GERI timers loose power those connections should no longer be active.

    I cant figure out why the generator was still running.

    Great progress just needs some tunning.

    Kwinn, when your done reading this book long forum comments will you please let me know why you think it did not shut down or activate at at 12.3volts????? Thanks
  • kwinnkwinn Posts: 7,512
    edited May 14 Vote Up0Vote Down
    I started this test at 6:15 pm (6:17pm grunting with octave change in engine sound) powering up the 4 and 3 stage battery chargers. Started at 13.5 and 13.4 volts input.

    Form there it counted and counted. The 9,000 had started the generator.

    I looked at the 9,000 at 8:20pm. The BS2 had shut down," The 9000's", two digital timer relays for some unknown programmed variable. Both digital timers were "OFF" .
    OK, that means the CONV constant is a bit low and needs to be changed to get more accurate timing. Make the changes listed in the code section below.
    Green LED And Bi Led still actively blinking. Generator was still running. Battery banks were at 13.8volts.
    That is normal wether the generator is on or off. The bi Led flips between colors every time the BS2 takes a voltage reading, and it takes 8 readings, averages them, and reports the average. The green LED flips between on and off each time it executes the entire program loop so it blinks much slower.
    You need to add a led to monitor each relay so you can see if it is on or off, or to look at the debug output.



    I manually shut down the generator by holding down the lit up Onan switch.
    I went back in my house...............The BS2 powered 9,000 started the generator up by itself at 13.7volts.
    [/quote]
    RUNON     CON          4     'Run time period in minutes for the generator
    RUNOFF    CON          1      'Generator off time in minutes before it will restart
    .
    .
    CONV      CON          60      'Multiplier to convert minutes to loop counts. 
    
    

    Can you make the code changes above, run the program while the battery voltage is above 12.3V, then remove the Vin+ wire for a few seconds, take a screen shot of the debug output and post it for me.

    I suspect the main problem is we are not providing the correct signals to the FOB and/or generator. Can you post any manuals or information you have on them?
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Just as I was going to unplug the box to bring it into the house to reprogram it the generator started up. The voltages were "12.3 ,12.6,12.7, 12.3" . It was just flickering at 12.3 to 12.4.
    I have saved your "third format" code revisions.
    I am going to let the unit run for 8700 seconds.
    In a few hours we will see if it needs the revised code.
    I will have to wait until an estimated 8:30pm to see if its cycling properly.

    I now understand that the box needs two momentary buttons on the outside connected to the remote.
    This would be in case I want to "stop" "start" over ride the BS2's controls of the wireless remote.
    In order to shut down the BS2 I have to unplug three power sources.
    Thanks for the code Kwinn
  • It fails. I cannot shut off the BS2 because the 219's back feed power to the board. The BS2's commands to the wireless remotes fail to stop the generator.
    It starts up at random and runs all day never shutting off.
    The voltage levels have no affect on when the generator starts.
    Even the momentary buttons I connected to the remote have intermittent operation.
    The wireless signal is fighting all the aluminum in the RV.
    I cant even turn off the run away power supply with the Onan switch.
    Hold it down for the same amount of time and let off it will start back up.
    When the com and con are connected on the GERI at power only the battery still stays connected even when the wires are completely disconnected from the control box.
  • ok i will copy the code from here to a laptop an use a DEBUG to get info.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    '
    [ Battery/Generator Charge Controller ]
    '
    ' File...... INA219 Battery Charge Controller.bs2
    ' Purpose... To monitor 2 battery packs and control a generator to maintain charge
    ' Author.... Kurt Winn
    ' Based on.. code by Tom Crawford (with Thanks to Parallax and Nuts & Volts for i2c code)
    ' Started... May 2017

    '
    [ Program Description ]
    'The main program calls INA219Init to verify the existance of the two devices,
    'then just loops, reading and displaying the bus voltage.
    'If the bus voltage drops to or below the VMIN level it activates 2 relays
    'INA219Init looks for a device at $80 and S81 on the i2c bus 'that appears to
    'behave like an Ina219

    'INA219ReadBus returns the bus voltage in i2cData in millivolts

    'The i2c routines are cribbed from Nuts and Volts Column 119, November 2004
    'They are modified to handle 16-bit registers
    'I chose not to tune them for the INA219, but left them general in case other
    'devices are on the bus.

    '
    [ Revision History ]
    'Initial Version:


    '
    [ I/O Definitions ]
    '
    RY1 PIN 0
    RY2 PIN 1
    BICLED1 PIN 3
    BICLED2 PIN 4
    GRNLED PIN 14
    SDA PIN 7
    SCL PIN 8

    '++++++++++++i2c constants++++++++++++++++
    Nak CON 1
    Ack CON 0
    INA219Sl1 CON $80 'slave1 address
    INA219Sl2 CON $81 'slave2 address
    '++++++VOLTAGE MIN & GENERATOR RUN TIME VALUES++++++
    VMIN CON 12300 'Voltage in millivolts to start generator
    RUNON CON 4 'Run time period in minutes for the generator
    RUNOFF CON 1 'Generator off time in minutes before it will restart
    ' Minutes to loop count converted constants
    CONV CON 60 'Multiplier to convert minutes to loop counts
    Genon CON RUNON + RUNOFF * CONV
    Genoff CON RUNOFF * CONV
    '+++++++++++++Variables++++++++++++++++++++
    TMAX VAR Word 'time to run the generator
    i2cReg VAR Word 'register within the slave device (allows for 16-bit)
    i2cData VAR Word 'data to/from device (allows for 16-bit writes and reads)
    i2cWork VAR Byte 'work byte for TX routine
    i2cSlv VAR Byte 'slave address
    i2cAdL VAR Nib 'address length: 0, 1, or 2
    i2cDaL VAR Bit 'data Length 0 => 1 Byte, 1 => 2 bytes
    i2cAck VAR Bit 'Ack Bit

    VbusM VAR Word


    q0 VAR i2cData ' alias namees, reuse variables.'z0 VAR power
    temp VAR Word
    rm VAR Word
    ix VAR Nib
    lc VAR Nib
    reps VAR Nib

    Begin:
    i2cSlv = Ina219Sl1 'slave address
    GOSUB INA219Init 'look for INA219 #1 on i2C bus
    i2cSlv = Ina219Sl2 'slave address
    GOSUB INA219Init 'look for INA219 #2 on i2C bus
    LOW RY1
    LOW RY2
    LOW BICLED1
    HIGH BICLED2
    TMAX = 0
    DO ' Main program loop
    IF lc = 0 THEN ' Header for logging status
    TOGGLE GRNLED
    DEBUG CR,"lc TMAX Gen Volt1 Volt2 ",CR
    lc = 15
    ENDIF
    'read both INA219's and select lowest reading
    i2cSlv = Ina219Sl1 'slave address for INA #1
    GOSUB Vavg 'get average reading1
    temp = VbusM 'store temprarily
    i2cSlv = Ina219Sl2 'slave address for INA #2
    GOSUB Vavg 'get average reading2
    'output status
    DEBUG DEC2 lc," ", DEC4 TMAX, " "
    IF TMAX <= Genoff THEN
    DEBUG "OFF "
    ELSE
    DEBUG "ON "
    ENDIF
    DEBUG DEC2 VbusM/1000,".", DEC2 temp
    DEBUG " ", DEC2 VbusM/1000,".", DEC2 VbusM,CR

    IF VbusM > temp THEN VbusM = temp 'select lowest reading

    ' See IF the generator should be turned ON or OFF
    SELECT TMAX
    CASE 0
    IF VbusM <= VMIN THEN
    TMAX = Genon
    HIGH RY1
    HIGH RY2
    ENDIF
    CASE Genoff
    LOW RY1
    LOW RY2
    TMAX = TMAX - 1
    CASE ELSE
    TMAX = TMAX - 1
    ENDSELECT
    lc = lc - 1
    PAUSE 500
    LOOP

    Vavg:
    reps = 8
    VbusM = 0
    DO WHILE (reps > 0)
    TOGGLE BICLED1
    TOGGLE BICLED2
    GOSUB INA219ReadBus 'get voltage from selected INA
    VbusM = VbusM + (i2cData >> 3)
    reps = reps -1
    LOOP
    RETURN

    ina219ReadBus: 'reurns bus voltage in i2cData in millivolts
    i2cAdL = 0 'no internal address
    i2cDaL = 0 'one byte of data (Address of reg to read)
    i2cData = $0002 'will be reading the bus voltage
    GOSUB i2cWrite 'set the pointer register
    i2cDaL = 1 'will read two bytes
    GOSUB i2cRead 'read bus voltage
    i2cData = (i2cData >> 1)'align bits to return mv
    RETURN


    ina219Init: 'look for unit at Ina219Slv Address
    i2cAdL = 1 'one byte of internal address
    i2cDaL = 1 'two bytes of data
    i2cReg = 0 'select Configuration Register
    i2cData = $8000 'reset bit
    GOSUB i2cWrite 'write the reset bit
    i2cAdL = 0 'no register address at all for read
    GOSUB i2cRead 'results of reset
    IF (i2cData = $399F) THEN
    DEBUG "Ina219 Ready", CR
    ELSE
    DEBUG "Ina219 Not Ready. Config Reg: ", HEX4 I2cData, CR
    ENDIF
    RETURN

    '+++++++++++++++general purpose i2c IO routines+++++++++++++
    i2cWrite: 'write to specified register
    GOSUB i2c_Start
    i2cWork = i2cSlv & $FE 'make certain no read bit
    GOSUB i2c_TX_Byte 'send slave address
    IF (i2cAck = Nak) THEN i2cWrite 'repeat until we get an Ack
    IF (i2cAdL > 0) THEN 'see if any internal address at all
    IF (i2cAdL = 2) THEN
    i2cWork = i2cReg.BYTE1 '16-bit internal address
    GOSUB i2c_TX_Byte 'high order internal address
    ENDIF
    i2cWork = i2cReg.BYTE0
    GOSUB i2c_TX_Byte 'low order internal address or 8-bit address
    ENDIF
    IF (i2cDaL = 1) THEN
    i2cWork = i2cData.BYTE1 'high order byte
    GOSUB i2c_TX_BYTE 'send it
    ENDIF
    i2cWork = i2cData.BYTE0 'actual data to write (lo order) (or only data byte)
    GOSUB i2c_TX_Byte 'write it
    GOSUB i2c_Stop
    RETURN

    i2cRead: 'read from specified register
    GOSUB i2c_Start
    i2cWork = i2cSlv | $01 'force read bit read bit
    GOSUB i2c_TX_Byte 'send slave address
    IF (i2cAck = Nak) THEN i2cWrite 'repeat until ack
    IF (i2cAdL > 0) THEN 'see if any internal address at all
    IF (i2cAdL = 2) THEN
    i2cWork = i2cReg.BYTE1 '16-bit internal address
    GOSUB i2c_TX_Byte 'high order internal address
    ENDIF
    i2cWork = i2cReg.BYTE0
    GOSUB i2c_TX_Byte 'low order internal address or 8-bit address
    ENDIF
    IF (i2cDaL = 1) THEN
    GOSUB i2cRead_Ack 'read the high order byte
    i2cData.BYTE1 = i2cWork 'high order byte
    ENDIF
    GOSUB i2cRead_Nak 'read the low order (or only) byte
    i2cData.BYTE0 = i2cWork 'save it
    GOSUB i2c_Stop
    RETURN

    '
    Low level i2c subroutines
    'These are cribbed exactly from Nuts and Bolts

    i2c_Start:
    INPUT SDA
    INPUT SCL
    LOW SDA
    clock_Hold:
    DO : LOOP UNTIL (SCL =1) 'wait for clock release
    RETURN

    i2c_TX_Byte:
    SHIFTOUT SDA, SCL, MSBFIRST, [i2cWork\8] 'send byte to device
    SHIFTIN SDA, SCL, MSBPRE, [i2cAck\1] 'get ackn bit
    RETURN

    i2cRead_NAK: 'read one byte
    i2cAck = NAK 'this is the last byte
    GOTO i2cRX
    i2cRead_ACK:
    i2cAck = ACK 'plan on doing more byte(s)
    i2cRX:
    SHIFTIN SDA, SCL, MSBPRE, [i2cWork\8] 'read the actual byte
    SHIFTOUT sda, scl, LSBFIRST, [i2cAck\1] 'acknowledge bit
    RETURN

    I2C_Stop:
    LOW SDA 'i2c stop bit sequence
    INPUT SCL
    INPUT SDA
    RETURN
  • kwinnkwinn Posts: 7,512
    Just as I was going to unplug the box to bring it into the house to reprogram it the generator started up. The voltages were "12.3 ,12.6,12.7, 12.3" . It was just flickering at 12.3 to 12.4.
    I have saved your "third format" code revisions.
    I am going to let the unit run for 8700 seconds.
    In a few hours we will see if it needs the revised code.
    I will have to wait until an estimated 8:30pm to see if its cycling properly.

    I now understand that the box needs two momentary buttons on the outside connected to the remote.
    This would be in case I want to "stop" "start" over ride the BS2's controls of the wireless remote.
    In order to shut down the BS2 I have to unplug three power sources.
    Thanks for the code Kwinn

    The first two lines of the code revisions were to shorten the on/off cycle for troubleshooting. The third line was to make the timing more accurate.

    Looks to me like going through the EAZY and GERI to control the generator is more of a problem than controlling the generator directly. From the following description from the generator manual this is the sequence of events to start the generator:

    1. Make certain the generator is on a flat, level surface.
    2. Turn off all electrical loads connected to the generator. Never start or stop the generator with electrical devices plugged in and turned on.
    3. Turn the Fuel Valve to the "ON" position.
    4. Press the Battery Switch to "ON".
    5. Press the Ignition Switch to "ON".
    6. WIRELESS REMOTE START: press and release the "START" button on the handheld Remote Control device. DO NOT hold the button down, only press the button once. The engine will attempt to start six times.
    7. A safety feature is provided which delays the electrical power availability during starting mode. The delay lasts for approximately 15 seconds. The delay is provided to prevent damage to the generator if electrical loads are inadvertently turned on during engine startup.

    Here are my thoughts on how the BS2 could perform the functions by controlling relays directly rather than through the EAZY and GERI boards:

    3 From prior posts it sounds like there is a permanent gravity fed fuel flow. If required a solenoid valve could be added to turn fuel flow on/off.
    4 Wire a relay with an adequate current rating in parallel with the battery ON switch.
    5 Wire a relay with an adequate current rating in parallel with the ignition ON switch.
    6 Wire a relay with an adequate current rating in parallel with the the wireless remote start on switch.

    The current two relays can connect to the fob remote start and stop buttons, and an additional double pole relay would turn on the battery and ignition circuits. A push button or switch could be added to manually override the BS2 and turn the generator on and off.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • Why are the 219's powering the BS2? The 219's are supposed to convert 26volts through 0 volts on input side.
    The output is supposed to be 5 volts to 0 volts at the BS2. How are they powering the board???
  • I think its time to explore other options. Maybe a direct wire to the BS2?
    The BS2 cannot directly switch high amp relays.
    Three p.c. board micro 1 amp 12 volt relays to connect the coils to ground on three high amp relays.
    I think that would work.
    Problem is how do I shut down the runaway magneto ignition system?

    I can shut that "battery switch" off and it will stay running
  • The other problem is Champion has six wires on the back of that ignition switch.
  • The method I have used to detect voltage just fails. The 219's may work for low amp applications. They don't work for high amp 12 volts.
  • Tomorrow I will drive the RV someplace an connect the laptop.
    I will give the current project configuration one more try.

    I think the combined amperage of eight 12 volt batteries is just too many amps for the Adafruit INA219 current sensors.
  • I will drill a hole in the top of the box to stick a chopped pencil in so I can push reset.
    I think that after it is plugged in the generator needs to be shut down then push reset.
    I will cycle deep(everything off) with land line voltage tonight bringing it up to 13.8 volts by tomorrow afternoon.
  • The other option would be to change the code to "11700 millivolts".
    because 11.7 volts is below the 12 volt wall adapter powering the BS2.
  • kwinnkwinn Posts: 7,512
    Why are the 219's powering the BS2? The 219's are supposed to convert 26volts through 0 volts on input side.
    The output is supposed to be 5 volts to 0 volts at the BS2. How are they powering the board???

    The 219's are not powering the BS2, The BS2 is powering the 219. The 219 is measuring the voltage on Vin+ and the voltage difference between Vin+ and Vin-. For this project we only need the voltage on Vin+ so the voltage difference is ignored.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • kwinnkwinn Posts: 7,512
    I think its time to explore other options. Maybe a direct wire to the BS2?
    I agree, already suggested that in my last post. Now that I have access to the generator manual I can figure out how to do that.
    The BS2 cannot directly switch high amp relays.
    Three p.c. board micro 1 amp 12 volt relays to connect the coils to ground on three high amp relays.
    I think that would work.
    That's one option, and probably the simplest. The other is to use a relay driver that can drive the coils.
    Problem is how do I shut down the runaway magneto ignition system?

    I can shut that "battery switch" off and it will stay running
    I'm sure we can find a solution to that problem.

    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
  • kwinnkwinn Posts: 7,512
    The other problem is Champion has six wires on the back of that ignition switch.
    Might need two 2 pole relays to replace that switch.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.
Sign In or Register to comment.