Shop OBEX P1 Docs P2 Docs Learn Events
Installed switch to project, now battery gets hot and lcd screen flickers, need — Parallax Forums

Installed switch to project, now battery gets hot and lcd screen flickers, need

BigMikeBigMike Posts: 34
edited 2009-05-18 20:25 in BASIC Stamp
Hello Parallax,

I am finishing up a project for school right now and need some help. I'll try to make this as short and sweet as possible and answer questions later.

For a instrumentation and measurement lab I am in, my group partner and I have built an active exhaust system on a 600cc motorcycle using a BS2 HomeWork board.

Brief overview as follows: a pressure sensor is attached between the engine and muffler. Pressure in the exhaust system increases as the engine speed increases. As the pressure increases, I have a servo that operates a dump valve to bleed off the excess pressure. So as the pressure builds, the pressure sensor increases in voltage, a 831ADC converts signal, and Stamp outputs to servo to open the dump valve more or close it if the pressure drops.

Ok. So everything was working PERFECTLY until I installed a three way switch. The switch is very simple: Position (1) uses realtime input from pressure sensor and adjusts dump valve position accordingly, Position (2) keeps dump valve shut no matter what (so disables the system and exhaust goes through the muffler like normal), and Position (3) holds the dump valve wide open regardless of pressure.

I do not have a circuit drawn up yet but I will be working on this again tomorrow morning and I'll see about getting it for reference.

Here is the code, and please bear in mind that although I've owned a Stamp for a couple of years, I really don't have the experience I wish I had. In other words, go easy on me when you see this crazy program lol:

' {$STAMP BS2}
' {$PBASIC 2.5}
adc_old      VAR Word
position_old VAR Word
position_new VAR Word
Servo     PIN 0
Sensor    PIN 8
temp      VAR Word
position  VAR Word
location  VAR Word
pressure  VAR Word
' -- Start ADC Variables --
adcBits VAR Byte
CS PIN 15
CLK PIN 6
DataOutput PIN 5
' -- Finish ADC Variables --
' -- Start LCD Variables --
TX              PIN     1               ' serial output to LCD
    T2400       CON     396
    T9600       CON     84
    T19K2       CON     32
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
' -- End LCD Variables --
Reset:
  HIGH TX                               ' setup serial output pin
  PAUSE 100                             ' allow LCD to initialize
Main:
  SEROUT TX, LcdBaud, [noparse][[/noparse]LcdBLoff, LcdOn1, LcdCls] 'turn on backlight: "LcdBLon"
  PAUSE 250
' -- Buttons --
OA        PIN   2 ' Open Your *** Switch
btnWrkOA  VAR   Byte
CA        PIN   3 ' Close Your *** Switch
btnWrkCA  VAR   Byte
' -- End Buttons
adc_old=0
position_old=0
position_new=0

Start:
DO
  BUTTON OA, 0, 20, 200, btnWrkOA, 1, Open_*** ' Check Switches
  BUTTON CA, 0, 20, 200, btnWrkCA, 1, Close_***
position_new = (adcBits*3)+390                         ' 390 is CLOSED == 800 is WOT
position=(position_old+position_new)/2

IF position<550 THEN position=390 ' Keep your *** closed!!
IF position>800 THEN position=800 ' Prevent Servo over-rotation

IF btnWrkOA>0 THEN position=800 ' Open Your ***!!
IF btnWrkCA>0 THEN position=390 ' Close Your ***!!

FOR temp = location TO position STEP 9
  PULSOUT Servo, temp
NEXT
location=position

adc_old=adcBits ' Trying to average the adc changes!!
position_old = (adc_old*3)+390

'IF btnWrkOA<1 THEN
' GOSUB ADC_Data
'ELSEIF btnWrkOA<1 THEN
' GOSUB ADC_Data
'ENDIF

GOSUB ADC_Data
adcBits=(adc_old+adcBits)/2 ' Trying to average the adc changes!!
GOSUB Display
LOOP



ADC_Data:
HIGH CS
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits]
RETURN



Display:
IF btnWrkOA>0 THEN
  SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine1, "Fixed Exhaust  "]
ELSEIF btnWrkCA>0 THEN
  SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine1, "Fixed Exhaust  "]
ELSE
  SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine1, "Active Exhaust "]
  SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine2, "Sensor: ", DEC3 adcBits]
ENDIF
PAUSE 100
RETURN



Open_***:
'DEBUG HOME, "Open your ***!!"
SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine2, "FLOW BABY!       "]
PAUSE 100
position=800
GOTO Start



Close_***:
'DEBUG HOME, "Close your ***!!"
SEROUT TX, LcdBaud, [noparse][[/noparse]LcdLine2, "Plugged up!      "]
PAUSE 100
position=390
GOTO Start





I am using an Active Low circuit for my switch. Could this be the problem? Is that only designed for a momentary switch?

Everything worked great. The LCD worked great, etc. But with the switch in the LCD flickers from time to time and includes a mystery '_' underscore after each line

The system will only run for 30-40 seconds and then everything just turns off.

I am sure you need to see my diagram so I will work on that tonight and tomorrow and get it up here.

Any feedback in the right direction is greatly appreciated! I will reply back with circuit diagram soon-

Thanks
Mike

Comments

  • BigMikeBigMike Posts: 34
    edited 2009-05-13 17:22
    I forgot to add that this program so far has gone through 19 different revisions where some past features were removed, and this was all done in a wooden garage running off of laptop batteries and 2 cans of Monster energy drinks [noparse]:)[/noparse] I'm sure we've all been there, pulling late nighters right [noparse]:)[/noparse]

    As for all the Word variables, memory isn't a concern because this is as big as the program is going to get, there is no other scope for this program so I just made them all Word even if its not needed.

    I am not a big fan of GOSUB for small simple programs, but this entire program started off as the default ADC program and I just started adding to it. This program is far from the finished version that I will submit with the project.

    Mike
  • FranklinFranklin Posts: 4,747
    edited 2009-05-13 18:53
    If we can see the circuit we might be able to help. If your code works without the switch then the problem is not your code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Desy2820Desy2820 Posts: 138
    edited 2009-05-14 02:20
    How exactly did you wire the switch?· I'm thinking you might have forgotten a resistor somewhere.· For active low, it should look something like this:
    VDD--->Resistor (Try between 1-10 Kohm)--->switch----VSS.· If you forget the resistor, you'll short VDD to VSS when the switch closes.· The resistor limits the current when the switch closes.· The short causes the regulator to heat up, and it shuts down or severly limits the current.

    You can also wire it this way:· VDD--->switch--->resistor--->VSS.· For·a wiring example, check the PBASIC Reference Manual's "Button" command.· There's good examples of the correct way to wire a button/switch.· (Page 139 on paper, 143 in Adobe.)

    Hope this helps!

    Sorry, the PBASIC Reference Manual is actually the Basic Stamp Syntax and Reference Manual.

    Post Edited (Desy2820) : 5/14/2009 2:25:24 AM GMT
  • BigMikeBigMike Posts: 34
    edited 2009-05-15 15:44
    Update on this:

    I installed my switches using an active-low circuit, each with a 10k ohm resistor and a 330 ohm resistor.

    I still have not had time to draw the circuit, but after spending a good portion of yesterday working out some bugs and cleaning up the code I have now narrowed down the problem to the following:

    The LCD Screen FREAKS OUT when ever the servo is moving or is under going a load. For instance, if you power the circuit on and everything is stationary, and the LCD reads "Hello", everything is great until you press against the servo horn and load the servo. Once the servo starts squealing to hold it's position, the LCD screen starts refreshing at a very high rate and displays text on top of other text, flickers like crazy, and then simply turns off if the servo is loaded for about 5 consecutive seconds.

    So what can I do to prevent the servo motor from producing feedback to my Stamp? Do I install a diode on the Vdd wire or should I install a capacity across the Vdd and Vss wires? The LCD is a 2x16 line with yellow backlight using a 3-wire plug, Red Vdd, Blck Vss, White serial wire.

    My servo is using P0 and my LCD screen is using P1. Would moving them further away from one another prevent this interference?

    Thanks! I've almost got this figured out!
    Mike

    Post Edited (BigMike) : 5/15/2009 3:50:27 PM GMT
  • FranklinFranklin Posts: 4,747
    edited 2009-05-16 02:39
    Do you have a seperate power supply for the servo? If not I'd start there. Remember to tie the drounds together.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • BigMikeBigMike Posts: 34
    edited 2009-05-16 03:54
    No, I am using the stamp's Vdd to power the servo.

    Not a problem at all for this as I have a 5 volt clamp that I can use with a 9v battery just for the servo. 10-4 on the grounds [noparse]:)[/noparse]

    I'll give that a try on Sunday when we need to have this project finished-

    Mike
  • pwillardpwillard Posts: 321
    edited 2009-05-17 02:14
    Powering the servo with Vdd = Bad Practice

    No Isolation... means motor noise coupling
    With the servo and LCD, the load can exceed on-board regulator's design parameters causing circuit freak-out...
    You could be getting unexpected resets...

    Just use a separate battery supply for SERVO with a common ground.

    You could use the same master supply if you had to... but use a separate 5v-6V regulator for the servo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    There's nothing like a new idea and a warm soldering iron.

    Post Edited (pwillard) : 5/17/2009 2:19:24 AM GMT
  • BJC_BulldogBJC_Bulldog Posts: 4
    edited 2009-05-17 04:08
    Hey Mike it's Brandon (if the word "ME115" makes sense to you then this is the person I'm thinking of) -- I have an extra power supply (4.5 V, 400 mA) I could let you use if you need. Shoot me an email if you want -- first part "bjchisum", suffix is our school suffix. We had some problems with this LCD/servo tie as well, but using a separate power supply yet making sure they all share the same ground is really important -- our card dealer started throwing cards off the table when i hooked it up first; it was kind of bouncing at the servo's extreme position. I'm pretty sure this is the heart of the problem.

    I thought this was working really well last week, but I guess you hadn't installed the switch yet. Regardless, good luck to you both, let me know if you need that power supply.

    Brandon
  • BigMikeBigMike Posts: 34
    edited 2009-05-17 04:24
    Thanks for all the tips guys!

    Brandon,

    Yup this is Mike from ME115 [noparse]:)[/noparse] When we brought the bike over it was functional but the LCD Screen was disabled at the time and the entire circuit would auto-poweroff after about 3-5 mins continuous use.

    I completely re-wrote the code, added a ton of performance features such as bypassing the adc when in one of the two manual mode as well as other features, rewired the board and fine tuned the resistance of each potentiometer and now have a far wider range or resolution to control the throttle body with. Now it is ultra smooth, much more responsive, and simple to adjust as all limit points have been consolidated into separate variables. Besides the LCD power glitch issue, it is working really great!

    Regarding the servo power supply, I am a full-on R/C lifer and have plenty of parts for the job. My Axial rock crawler's CS170 servo is powered by two NTE962 6.2v clamps running in parallel, over 340 oz/in torque. Compare $2 for the two clamps vs $45+ for the Castle Creations adjustable BEC + USB cable and software. I also have a couple 4-AA battery packs designed for BECs that I will use if we run out of time.

    Can't wait to see your card dealer, it sounds really cool!

    BigMike
  • BigMikeBigMike Posts: 34
    edited 2009-05-18 20:25
    Update-

    Thanks for the advice gentlemen, the power supply for the servo did the trick! [noparse]:)[/noparse]

    I incorporated the LCD in a couple other areas of the project, and even removed all LCD pauses and it still works beautifully.

    Also the "mysterious" underscore "_" that was appearing at the end of each line is no more [noparse]:)[/noparse]

    Thanks everyone!
    Mike
Sign In or Register to comment.