Hi, I have just started programming in Basic and for processors, and I'm a little confused on the logic and syntax.
Here's my program, written in PBasic:
'Automatic Car.bs2
'UWO Formula Racing Team
'September 2, 2010
'Allows for switched Manual, Automatic, or Launch Control transmission variations
'To be used with the 2010 FSAE Pneumatic Switching board
'RPMs are to be input AFTER the ECU, for a digital signal.
'Main program - Based on selector switch mode:
'S_MAN (Manual Transmission) ->
'In Manual mode, the shift buttons are directed straight to the external
'Shifting board, activating the shifting mechanisms.
'S_AUTO (Automatic Transmission) ->
'In Automatic mode, the shift buttons are activated when engine RPM hits
'The prime shift point (12,000 RPM)
'S_LAUNCH (Launch Control) ->
'In Launch Control mode (designed for Acceleration Run), the processor has
'Three states: Pre-launch, < 3500 RPM, allows for manual gear changes.
'During Launch, > 3500RPM, activates Launch Control and becomes Automatic
'Post Launch, after first gear change, deactivates Launch Control
Main:
IF S_MAN = IsOn THEN GOSUB Manual
IF S_AUTO = IsOn THEN GOSUB Automatic
IF S_LAUNCH = IsOn THEN GOSUB Launch
GOTO Main
END
Manual:
DO WHILE S_MAN = IsOn
BUTTON B_DWNIN, IsOn, 255, 0, B1_WRK, 1, Downshift
BUTTON B_UPIN, IsOn, 255, 0, B2_WRK, 1, Upshift
LOOP
RETURN
Automatic:
DO WHILE S_AUTO = IsOn
COUNT RPM_IN, CountMs, RPM_PULSE
RPM_VAL = RPM_PULSE * RPMConst
IF RPM_VAL < 3500 THEN
GOSUB Downshift
ELSEIF RPM_VAL >= 12000 THEN
GOSUB Upshift
ENDIF
LOOP
RETURN
LOW LC_IN
DO WHILE S_LAUNCH = IsOn
COUNT RPM_IN, CountMs, RPM_PULSE
RPM_VAL = RPM_PULSE * RPMConst
IF RPM_VAL >= 12000 THEN
GOSUB Upshift
ELSEIF RPM_VAL < 3500 THEN
GOSUB Downshift
ENDIF
LOOP
RETURN
Downshift:
PULSOUT B_DWNOUT, 50
RETURN
Upshift:
PULSOUT B_UPOUT, 50
HIGH LC_IN
RETURN
I think I've done it right, but my question is for LC_IN. LC_IN is a pin from the ECU that's held high at 4.5V and is active LOW. So to activate the ECU pin, do I make my Basic Stamp pin LOW, or do I make it an Input?
Thanks!
Paul
Well, thanks to anyone who looked, but I got my answer from a friend:
LOW (pin number) grounds the pin. It's still considered an Output because you're writing a value to the pin.