Shop OBEX P1 Docs P2 Docs Learn Events
need bulletproof circuit to run bs2 & serial 2x16 backlit lcd in agricultural harvester — Parallax Forums

need bulletproof circuit to run bs2 & serial 2x16 backlit lcd in agricultural harvester

sport270sport270 Posts: 82
edited 2015-10-15 19:47 in BASIC Stamp
have been having issues with a bs2 & serial lcd screen. Some were lasting a mere couple hours. some lasted a few days. but all eventually failed. must be something not protected in the power supply circuit. might be my program. and lastly it might be static discharge as these build up static running in the cold dry dusty conditions. or if anyone has another type lcd display more heavy duty they recommend....
Here is my code if anyone can look it over. two places of interest are : RESET at one point I had the pause 1000 below the HIGH TX
and the pause 250 above...... petty sure that messed up the now communication before power up of lcd.
Next is at X3X_SPEED I think I should divide by 100 then multiply by 162 to get correct hz /rpm reading without going over the
65,000 count limit ..... 420hz *162=68,040 /100=680 rpm/hz ..... vs .... 420hx/100=4.2*162=680 rpm/hz
my schematic is posted below the code....sorry about how I layed it out on schematic..... but its definitely better looking than my actual circuit...lol Jeff sport270@yahoo.com 806-939-2245
<
' {$STAMP BS2}
' {$PBASIC 2.5}
' FES LCD 12/18/14
'
'
[ I/O Definitions ]

TX PIN 15 ' serial output to LCD


'
[ Constants ]

#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2PE
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
#CASE BS2PX
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
#ENDSELECT

LcdBaud CON T19K2

LcdBkSpc CON $08 ' move cursor left
LcdRt CON $09 ' move cursor right
LcdLF CON $0A ' move cursor down 1 line
LcdCls CON $0C ' clear LCD (use PAUSE 5 after)
LcdCR CON $0D ' move pos 0 of next line
LcdBLon CON $11 ' backlight on
LcdBLoff CON $12 ' backlight off
LcdOff CON $15 ' LCD off
LcdOn1 CON $16 ' LCD on; cursor off, blink off
LcdOn2 CON $17 ' LCD on; cursor off, blink on
LcdOn3 CON $18 ' LCD on; cursor on, blink off
LcdOn4 CON $19 ' LCD on; cursor on, blink on
LcdLine1 CON $80 ' move to line 1, column 0
LcdLine2 CON $94 ' move to line 2, column 0

LcdCC0 CON $F8 ' define custom char 0
LcdCC1 CON $F9 ' define custom char 1
LcdCC2 CON $FA ' define custom char 2
LcdCC3 CON $FB ' define custom char 3
LcdCC4 CON $FC ' define custom char 4
LcdCC5 CON $FD ' define custom char 5
LcdCC6 CON $FE ' define custom char 6
LcdCC7 CON $FF ' define custom char 7
'
'
'
DIR0 = 0 'pin to read left saw or X1X
DIR1 = 0 'pin to read right saw or X2X
DIR2 = 0 'Pin to read xauger or X3X
DIR3 = 0 'pin to read pot for alarms on saws or A1A and is also A2A
DIR4 = 0 'pin to read pot for alarm on xauger or A3A
DIR5 = 0 'pin to turn on buzzer connected to blue pulsing buzzer through transistor
DIR6 = 0 'pin to turn on led for Left saw
DIR7 = 0 'pin to turn on led for right saw
DIR8 = 0 'pin to turn on led for cross auger
DIR9 = 0 ' pin saved to read GROUND SPEED at later date
DIR10 = 0 '
DIR11 = 0 '
DIR12 = 0 '
DIR13 = 0 '
DIR14 = 0 '
DIR15 = 0 '
'
[ Variables ]

X1X VAR Word ' variable tag for rpm value of Left saw
X2X VAR Word ' variable tag for rpm value of right saw
X3X VAR Word ' variable tag for rpm value of xauger
A1A VAR Word ' variable tag for alarm set point of BOTH saws
A2A VAR Word ' variable tag for alarm set point of right saw
A3A VAR Word ' variable tag for alarm set point of cross auger
ALARM VAR Word ' variable tag to turn on alarm

'
[ Initialization ]

Reset: '
PAUSE 1000 '************AT ONE POINT THIS WAS BELOW THE "HIGH TX" LINE********
HIGH TX ' setup serial output pin
PAUSE 250 ' allow LCD to initialize


'
[ Program Code ]

' Clear the display and remove cursor and blinking attributes.

Main:
SEROUT TX, LcdBaud, [LcdBLon, LcdOn1, LcdCls] '
PAUSE 250 '
'
'
DO '
'
GOSUB Pot_SAWS ' GET pot for alarms on saws
'
GOSUB Pot_XAUGER ' GET pot for alarm on Xauger
'
'GOSUB X1X_SPEED 'GET SPEED OF LEFT SAW WITH COUNT
'
GOSUB X2X_SPEED 'GET SPEED OF RIGHT SAW WITH COUNT
'
GOSUB X3X_SPEED 'GE SPEED OF XAUGER WITH COUNT
'
GOSUB Compare ' compare rpms to alarm set points
'
'gosub Set_ALARMS ' did this in compare
'
GOSUB Update_LCD ' refreshes lcd display
'
' '
LOOP '

'
[ Subroutines ]

Update_LCD:
SEROUT TX, LcdBaud, [LcdLine1, " ", DEC3 X3X, " ",DEC3 X3X, " ", DEC3 X2X]
SEROUT TX, LcdBaud, [LcdLine2, " ", DEC3 A3A, " ",DEC3 A3A, " ", DEC3 A2A]
RETURN






'NEW CODE BLOCKS************************************
'
'
'

'
'

'
'
'
'*************************************

Pot_SAWS: 'input pin 03 .. 10K TRIMPOT, .1uf cap and 220 ohm in series to
'
A1A = 0 'reset to 0
HIGH 3 'precharge the cap
PAUSE 100 '
RCTIME 3,1,A1A '
PAUSE 10 '
'debug "A1A is ",DEC A1A,CR 'used to get real scale
'
'
A1A = A1A +500 ' Add to or change scale to get into the range needed
'
DEBUG "A1A is ",DEC A1A,CR '
'
PAUSE 100 '
'
A2A = A1A 'sets alarm for right saw the same as left
'
RETURN '

'******************************
'
'
'

Pot_Xauger: 'input pin 04 .. 10K TRIMPOT, .1uf cap and 220 ohm in series to
'
A3A = 0 'reset to 0
HIGH 4 'precharge the cap
PAUSE 100 '
RCTIME 4,1,A3A '
PAUSE 10 '
'debug "A3A is ",dec A3A,CR 'used to get real scale
'
'
A3A = A3A +500 ' Add to or change scale to get into the range needed
'
DEBUG "A3A is ",DEC A3A,CR '
'
PAUSE 100 '
'

'
RETURN '
'
'
'**********************************
'
'
X1X_SPEED: 'get speed of left saw on pin 0
'
COUNT 0,500,X1X ' count pin 0 for 1/2 second
X1X = X1X*2 ' correct reading to full second
DEBUG "X1X IS ",DEC X1X,CR '
PAUSE 100 '
RETURN '
'
'
'###################################
'
'

X2X_SPEED: 'get speed of RIGHT saw on pin 1
'
COUNT 1,500,X2X ' count pin 1 for 1/2 second
X2X = X2X*2 ' correct reading to full second
X2X = X2X/100 '
X2X = X2X*105 '
DEBUG "X2X IS ",DEC X2X,CR '
PAUSE 100 '
RETURN '
'
'
'**********************************
'
'

X3X_SPEED: 'get speed of left saw on pin 2
'
COUNT 2,500,X3X ' count pin 2 for 1/2 second
X3X = X3X*2 ' correct reading to full second ******THINK I NEED TO SWAP THE NEXT 2 LINES BELOW AND / BEFORE *
X3X = X3X/100 ' CORRECT for 37 tooth gear multiply by 1.62 or *162 then divide by 100
x3x = X3X*162 ' correction for decimal value
DEBUG "X3X IS ",DEC X3X,CR '
PAUSE 100 '
RETURN '
'
'
'********************************
'
'
COMPARE: ' COMPARE SPEEDS TO ALARM SETPOINTS
'
GOTO X3B '
'
IF X1X > A1A THEN X2A '
ALARM = ALARM +1 'FLAG TO SET ALARM IF ANY ARE BELOW SETPOINT
HIGH 6 ' turn on left saw led
'
'
GOTO X2B '
X2A: '
LOW 6 '
X2B : '
'
IF X2X > A2A THEN X3A '
ALARM = ALARM +1 ' FLAG FOR ALARM
HIGH 7 ' turns on right saw led
'
'
' '
GOTO X3B '
'
'
X3A: '.
LOW 7 '
'
X3B: '
'
'
'
IF X3X > A3A THEN Alarm_SET_A '
ALARM = ALARM +1 '
HIGH 8 ' turns on cross auger led
'
GOTO Alarm_SET_B:


Alarm_SET_A: '
'
LOW 8 '
Alarm_SET_B: '
IF ALARM <0 THEN A_ON '
PAUSE 100 'PAUSE LONG ENOUGH TO CHARGE CAP TO KEEP LED & BUZZER CONSTANT AND NOT INTERMITTENT
ALARM=0 'RESET ALARM FLAG
LOW 5 'TURNS OFF BUZZER
'LOW 6 'TURNS OFF left saw LED
'LOW 7 ' turns off right saw led
'LOW 8 ' turns off cross auger led
RETURN '
'
A_ON: 'TURNS ON ALARMS & BUZZER
'
HIGH 5 'turn on buzzer
PAUSE 100 'PAUSE LONG ENOUGH TO CHARGE CAP TO KEEP LED & BUZZER CONSTANT AND NOT INTERMITTENT
ALARM=0 'RESET ALARM FLAG
'LOW 5 'TURNS OFF BUZZER
'LOW 6 'TURNS OFF left saw LED
'low 7 ' turns off right saw led
'low 8 ' turns off cross auger led
'
RETURN
'
'
'Z**********************************

>






























LCD%20SCHEMATIC.pdf

Comments

  • Both the Stamp and the serial LCD are pretty robust most of the time. Power spikes and connecting them backwards are the exception. I'd not use the 7812 regulator. First of all, it's not really regulating since its input voltage is close to its output voltage. Secondly, you've got a perfectly good source of regulated +5V. Leave Vin unconnected and connect the Stamp's Vdd to the +5V supply. That doesn't explain the short lifetime of the display. Exactly what happens?

    I'm sure a harvester is a terribly noisy electrical environment let alone being dusty. All of your circuitry should be in a metal box with the box connected to circuit ground. The output of the 7805 should have a 0.1uF ceramic capacitor in parallel with a 10uF 10V electrolytic capacitor across it to ground. The input should have a 0.1uF ceramic capacitor across the 100uF electrolytic and both should be rated at 50V. There are automobile filter chokes designed to filter noise spikes on car battery powered accessories. Use one in series with the +12V input

    Can you use a 5V buzzer instead of the 12V buzzer, maybe a piezoelectric device? They're quite loud and would avoid having to use +12V in your circuit even though the TIP120 should isolate the rest of the circuit.
  • did the program look ok. nothing in it can cause the failures?
  • ok so one of the screens does nothing. no backlit. nothing.
    2nd one has backlit, plays music in demo mode,but no characters in any modes
  • As far as I know, there's nothing you can send to Parallax's serial display that will cause it to fail. Have you tried "test mode" and adjusting the contrast? I don't recommend using 19200 Baud with a BS2, but that won't cause a failure, just occasional incorrect or dropped characters. 9600 or 2400 Baud is better.
  • PublisonPublison Posts: 12,366
    edited 2015-10-15 23:48
    I'm assuming you have ground connected to the LCD? It does not show in your PDF.
  • Are all your connections soldered?

    I would add a 1k resistor between P15 and the LCD RX pin. The RX pin is sensitive to voltage, especially if Vdd is not on (the manual specifically warns about this). A resistor limits any current into the LCD should power be interrupted while P15 is high. It won't affect your data.
  • The TIP120 should also have a 4.7k resistor between it and the BS2, to limit current draw from the I/O pin and to limit the max current the TIP120 conducts. I don't see any filtering on the output of the 7805.

    If you want a bulletproof 5v supply, go look at the schematic for the Megasquirt, it's very robust and field tested.

    I'm also concerned about your mag sensors. I assume these are relatively far away from the BS2 module, if they are, you should be using shielded cable, grounding the shield at the BS2 side of the cable. This is to prevent interference finding its way into the cable and back to the BS2, potentially causing high voltage induced transients.

    I also see that you don't have all grounds connected together, the VSS signals on the BS2 should all be connected to ground and ground should have an excellent connection to the chassis ground.
  • edited 2015-10-20 20:03
    Have a look at adding a capacitor to the output of your 7805. I've done that, based on datasheet recommendations, with good results. Not sure if this will help you but it's good practice.
  • pedward wrote: »
    The TIP120 should also have a 4.7k resistor between it and the BS2, to limit current draw from the I/O pin and to limit the max current the TIP120 conducts. I don't see

    any 9filtering on the output of the 7805.

    If you want a bulletproof 5v supply, go look at the schematic for the Megasquirt, it's very robust and field tested.

    I'm also concerned about your mag sensors. I assume these are relatively far away from the BS2 module, if they are, you should be using shielded cable, grounding the shield at the BS2 side of the cable. This is to prevent interference finding its way into the cable and back to the BS2, potentially causing high voltage induced transients.

    I also see that you don't have all grounds connected together, the VSS signals on the BS2 should all be connected to ground and ground should have an excellent connection to the chassis ground.
    Sapphire wrote: »
    Are all your connections soldered?

    I would add a 1k resistor between P15 and the LCD RX pin. The RX pin is sensitive to voltage, especially if Vdd is not on (the manual specifically warns about this). A resistor limits any current into the LCD should power be interrupted while P15 is high. It won't affect your data.

  • Well I just got back in town from replacing the first of 4 failed lcd's.
    I added .01 caps on both sides of 7805 regulator along with 10uf on output & 100uf on input. I also only connected the 7805 to the stamp leaving the 12v input disconnected. I added a 1k between the RX pin of stamp & the lcd. I also added a 2k between stamp & tip120 .
    I changed the circuit for the signal input from the mag sensors. I ran the signal through a In4004 diode, then a 5k resistor
    Paralleled with a 10k resistor + .01cap to ground and a bzx55 zener diode to ground followed by a 2.2k before input to bs2.
    And I also grounded the console casing to the common ground for everything.
    After a few hours of use it is still operating.... :)
    Thanks for all the quick advice guys....
    I've got several more to do and have more time on my hand so I'm thinking about running the signal into a 74ls74 flip flop to have a buffer before the stamp. Any ideas if that would help isolate the stamp.? And I guess I would use another 74ls74 to buffer the outputs to the Led's. And maybe a ULN3000 to buffer the output to the Tip120....? Anybody have any reason this won't work or help isolate the bs2..?
  • Uln2003
  • I don't think you need the flip flop or the ULN. You have pretty good buffering now. Let it run some more and I think you'll be fine.
  • Mike Green wrote: »
    ... I'd not use the 7812 regulator. First of all, it's not really regulating since its input voltage is close to its output voltage.
    The harvester's engine is likely to have an alternator and voltage regulator. With the engine running the regulator will maintain a voltage of 14 V rather than the battery's nominal 12 V.
    The margin of 2 V should be enough for the 7812 to produce a stable 12 V.

Sign In or Register to comment.