Shop OBEX P1 Docs P2 Docs Learn Events
Cycling Champion generator control module useing BS2 detect 12v start\stop gen. batt. chargers — Parallax Forums

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

svparallax2017svparallax2017 Posts: 214
edited 2017-05-22 23:08 in BASIC Stamp
Is anyone good at writing code? Can anyone help me write the code for this? My device monitors 12volts from battery banks to activate 2 programmable timer relays. I need to ground out terminal 85 when the voltage is <12.3volts. The Arduino voltage sensors divide the voltage so the Parallax board can see it at 0 to 5 volts. The magic voltage number to activate the relay =< .06volts. The other way is to make the one output PIN "HIGH" to connect to a TIP31C transistor BUT the Parallax board only outputs 4.5volts. The transistor needs 5 volts to switch the relay.
«13456711

Comments

  • kwinnkwinn Posts: 8,697
    The Parallax board should be able to drive the TPIC31C, you just need a resistor between the I/O pin and the base of the transistor to limit the current. A 220 - 240 ohm resistor should be enough.
  • kwinnkwinn Posts: 8,697
    Post more info such as part numbers and schematics of what parts you have for more help.
  • ok but no pictures "the unploaded file was too big"..... Parallax HomeWprk Board /USB/basic stamp2,The GERI FRM01 programable timer,The EAZY VLC _V20 DUEL PROGRAMMABLE TIMER, and two "VCC<25V" tiny blue Arduino "voltage sensors,Arduino-Voltage-Sensor-0-25V , SONG CHUAN 896-1CH-D1 Coil:12VDC 40A/30A 14VDC C1012, RadioShack AC/DC adapter set at 12volts 2.5amps. Cannot use larger power source because I had 2 EAZY relays one just got angry hot and went on a permanent vacation in the trash can at 13.5volts.
  • I am going to Radio shack to get a "smaller transistor".I don't want to "float voltage at the Parallax board" if I can help it
    . I don't know how to code the input PINS 15 and 8 from the Arduino voltage sensors to write the "IF THEN" condition to get to the ADDRESS output PIN 0 or "HIGH 0". 0 Pin outputs voltage to the automotive relay (terminal 85) that the programmable relays (terminal 30) are connected to.
  • Which Parallax board are you using?
  • Publison asked : "Which Parallax board are you using?"
    The Parallax Home Work Board with the (16 pin?) BS2 . They sell "The Basic Stamp 2 Experiment Board" at Radio Shack.
    Radio Shack is going to announce a new bankruptcy chapter soon if they haven't already. I got this BS2 board for $16.
    All there products including the tiny stuff like "NPN Transistor 2N3904" is being liquidated now.
  • We just lost the last store where I live. It will close in 30 days. That will be 6 stores in a 50 mile radius. It is a very sad day
    for us DIY people.
  • kwinnkwinn Posts: 8,697
    We just lost the last store where I live. It will close in 30 days. That will be 6 stores in a 50 mile radius. It is a very sad day
    for us DIY people.

    Yes, it's sad to loose such a close and convenient supplier. OTOH it does not take long to get used to the convenience of ordering on line and having it delivered. It may not be as fast as running to the nearest store but there is so much more available.
  • kwinnkwinn Posts: 8,697
    ok but no pictures "the unploaded file was too big"..... Parallax HomeWprk Board /USB/basic stamp2,The GERI FRM01 programable timer,The EAZY VLC _V20 DUEL PROGRAMMABLE TIMER, and two "VCC<25V" tiny blue Arduino "voltage sensors,,SONG CHUAN 896-1CH-D1 Coil:12VDC 40A/30A 14VDC C1012, RadioShack AC/DC adapter set at 12volts 2.5amps. Cannot use larger power source because I had 2 EAZY relays one just got angry hot and went on a permanent vacation in the trash can at 13.5volts.

    Is the section in bold the relay you want to activate, and does it come on a board with a diode?
  • No it is a standard 30/40amp 12 volt automotive relay. The programmable relays are all set. In fact the remote is momentarily pressed with one of there outputs and it does start the generator right up. Writing the code to have the conditions for this address is the hard part. Well that and that I have only got the automotive relay to switch it all on with 12 volts not 4.5 from the BS2.
  • Kwinn asked "Is the section in bold the relay you want to activate, and does it come on a board with a diode?"

    There is no diode. Its just an (terminals 87,87a,30,85,86) relay. The coil is terminals 85 and 86.
  • Yes that is the relay I need to activate. Kwinn could you please help me write the code for this?
  • kwinnkwinn Posts: 8,697
    First, a caution. If you are running the BasicStamp HW Board from the 12V supply the regulator may overheat if there is too much current drawn from the +5V supply.

    I need a description or diagram of how your parts are connected. Here is a list of parts with my guess.

    1 - The Arduino Voltage Sensor 0-25V
    – Input comes from the battery pack and the output goes to the Voltage input of the EAZY VLC.

    2 – EAZY VLC
    - Input comes from the output of the Arduino Voltage Sensor 0-25V and the output relay goes to a pin on the Basic Stamp

    3 - GERI FRM01
    - ??

    4 – Basic Stamp
    - 2 inputs come from the EAZY VLC, and one output goes to a transistor that turns on #5, the relay.

    5 - SONG CHUAN 896-1CH-D1 Coil:12VDC 40A/30A 14VDC C1012
    - Output pin from the Basic Stamp drives a transistor connected to the relay coil.
  • 1 The basic stamp 2 board receives input from the Arduino voltage sensors

    2 IF THEN the voltage at the Basic Stamp is .06 volts (12.3volts) <<<<<<CONDITION

    3 "LOW 0" pin this energizes the SONG relay <<<<<ADDRESS

    4 When that relay IS activated the GERI and EAZY programmable relays turn on at same time

    Sorry to make you wait Kwinn. I am new to forum and doing exercises from book 'What is a Micro Controller' with board

    currently the "BiColorLed.bs2"
  • Kwinn, why doesn't the SONG relay activate when I program "LOW 0"???? I can activate Song relay when connected directly to "- Vss" or ground. Isn't the "LOW" command connect an input output pin to -Vss????
    It is a strong enough ground to do light the LED. Why not the negative side of SONG relays coil???
  • kwinnkwinn Posts: 8,697
    Kwinn, why doesn't the SONG relay activate when I program "LOW 0"???? I can activate Song relay when connected directly to "- Vss" or ground. Isn't the "LOW" command connect an input output pin to -Vss????
    The "LOW 0" command does set the specified pin low, but the pins can not supply enough current to drive most relay coils. That takes more current than the BS2 chip can provide. Also, having the relay coil connected to +12V may damage the BS2.
    It is a strong enough ground to do light the LED. Why not the negative side of SONG relays coil???

    A led only requires a few milliamps so the BS2 can do that directly. For components that need more current or higher voltages some form of driver is needed like the 2N3904 transistor you mentioned earlier.

    The relay you mentioned earlier needs 12V for the coil. How much current does it need? If that is not specified you can measure the resistance of the coil with a multimeter and calculate the current needed.
  • kwinnkwinn Posts: 8,697
    Ok, found the relay specs. The coil resistance is 90 ohms and the current is 133 mA. The 2N3904 you purchased can drive the relay.
  • kwinn wrote: »
    Ok, found the relay specs. The coil resistance is 90 ohms and the current is 133 mA. The 2N3904 you purchased can drive the relay.

    Unfortunately I tried the 2N3904 it did not activate the relay. My "HIGH" commands only output 1 volt so I am going to try a different relay to activate the EAZY programmable timer.

  • Do you know how to get the highest voltage out of the output pin?
  • kwinnkwinn Posts: 8,697
    Do you know how to get the highest voltage out of the output pin?

    As I mentioned in a prior post if you connected the relay coil to +12V and the BS2 you may have damaged the pin. Do not connect anything to the BS2 pins and then measure the voltage on the pin when you do a "HIGH 0" command. I will post a diagram of how the relay coil and transistor need to be connected to the BS2 when I get home.
  • kwinnkwinn Posts: 8,697
    Here is a generic diagram of how to connect the transistor and relay coil to the BS2. Diode D1 is very important and should be soldered as close to or preferably on the relay coil pins. That diode absorbs the current spike that occurs when the current to the coil is turned off. R1 in the diagram is not needed since it is already on the BS2 circuit board.
    781 x 367 - 13K
  • I got it to activate the EAZY programable duel relays with a Radio Shack "SPDT Micromini 12VDC Relay Rated 1A at 120AC/24VDC PC contacts" I took the 12volts from the back of my switch on the mouser box and wired it directly to the EAZY "+" terminal relay. Then I took the micromini relay and used it to connect the "-" terminal on the EAZY relay to ground circuit for the whole box. It works!!:) :) . I took the output "HIGH 0" PIN 0 and put it through a 2N3904 Transistor NPN sillicon. Instead of that giant space hog automotive relay now I have this tiny relay on the white board. The next thing on the agenda is to program the Parallax board to handle the input from the Arduino Voltage sensors "IN8" "IN15".
    Right now the code looks like this

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



    'Autonomous generator control module '
    'Detects voltage levels activates programmed relays to start electric start generator'

    counter VAR Byte

    FOR counter = 1 TO 9

    DEBUG ? counter




    HIGH 14
    PAUSE 350
    LOW 14
    PAUSE 350


    NEXT

    DEBUG ? IN8
    DEBUG ? IN15

    IF (IN15=0) THEN

    HIGH 0
    HIGH 4 'Red
    LOW 3
    PAUSE 250

    LOW 4 'Green
    HIGH 3
    PAUSE 250

    HIGH 4 'RED
    LOW 3
    PAUSE 250

    LOW 4 'GREEN
    HIGH 3
    PAUSE 250

    HIGH 4 'Red
    LOW 3
    PAUSE 250

    LOW 4 'Green
    HIGH 3
    PAUSE 250

    HIGH 4 'RED
    LOW 3
    PAUSE 250

    LOW 4 'GREEN
    HIGH 3
    PAUSE 250

    LOW 4 ' Off
    LOW 3
    PAUSE 250


    ELSEIF (IN8=0)THEN

    HIGH 0
    HIGH 4 'Red
    LOW 3
    PAUSE 250

    LOW 4 'Green
    HIGH 3
    PAUSE 250

    HIGH 4 'RED
    LOW 3
    PAUSE 250

    LOW 4 'GREEN
    HIGH 3
    PAUSE 250

    HIGH 4 'Red
    LOW 3
    PAUSE 250

    LOW 4 'Green
    HIGH 3
    PAUSE 250

    HIGH 4 'RED
    LOW 3
    PAUSE 250

    LOW 4 'GREEN
    HIGH 3
    PAUSE 250

    LOW 4 ' Off
    LOW 3
    PAUSE 250

    ENDIF
    DO
    LOOP
  • Problem is IF (IN15=0) THEN HIGH 0 was just a fake CONDITION to make hardware for the ADDRESS. Now I must program the BS2 to see the voltage from the sensors ?????????IF (IN15=<12.3volts) THEN HIGH 0"??????? I think it is actually only .06volts after the 12.3 volts passes through the voltage divider Arduino voltage sensor. Would that be written "IF (IN15=<.06volts) THEN HIGH 0" ????????? Thankyou. Kwinn
  • kwinnkwinn Posts: 8,697
    The voltage out from the Arduino voltage sensor 0-25V should be 12.3/5=2.46V.

    The I/O pins on the BS2 can not measure an analog voltage, only a digital high or low so it would be either 1 or 0 respectively. With an input voltage of 2.46V it could be either value. To measure the analog voltage you need an ADC.

    Can you explain the ultimate goal of this project?
  • What is an "ADC"??

    The BS2 senses voltage or receives input from battery banks.

    The BS2 outputs a command to start relay sequence to start a generator.
  • Isn't the "ADC" a part of the Arduino Voltage Sensors?
  • The DEBUG window says with no battery banks hooked up "IN8 =0"
    "IN15=0"

    How do I get it to see a "0" when the Arduino voltage divider sensors see .06 volts on the sensors output side?
  • The input side of Arduino voltage divider sensor must be 12.3 volts or 70% discharge
  • Thats when the RV is in a parking-lot someplace. The rooftop a/c has been running for a couple hours and I want the BS2
    to turn on that generator.
Sign In or Register to comment.