MS5607 Sensor and Controlling DC Motor
I've got the Board of Education with the MS5607 altimeter module and LCD display. The code for it is working great and it performs well, however, I would like to use pulse width modulation to control a motor as well based on the feedback from the sensor. Something such as if altitude is 7200 then the DC motor is at 100% but when it reaches 7250 it goes to 50%...Does anybody have a general idea about how to go about this? New to the Propeller scene. Thanks in advance.
Comments
http://obex.parallax.com/object/481
No luck with that....trying to trouble shoot my if statement first by making the lcd play a tone based on the if statement and I can't get that to work either. It is listed below:
OBJ
display : "FullDuplexSerial.spin"
alt : "29124_altimeter"
number : "FloatString"
CON
_clkmode = xtal1 + pll16x ' Sets frequency
_xinfreq = 5_000_000 '
TX_PIN = 2 'Sets pin for Rx communictation with LCD
BAUD = 19_200
START_ALT = 7200 ' Enters a reference elevation for the pressure to be calibrated off of.
PUB start | a, t, altitude 'Sets a,t,altitude as variables
display.start(TX_PIN, TX_PIN, %1000, 19_200) ' Start Parallax FullDuplexSerial.
waitcnt(clkfreq / 100 + cnt) ' Pause for FullDuplexSerial.spin to initialize
display.tx(17) ' Turn on display backlight
alt.start(alt#QUICKSTART, alt#BACKGROUND) ' Start altimeter for QuickStart with background processing.
alt.set_resolution(alt#HIGHEST) ' Set to highest resolution.
alt.set_altitude(alt.m_from_ft(START_ALT * 100)) ' Set the starting altitude, based on average local pressure.
repeat
a := alt.altitude(alt.average_press) ' Get the current altitude in cm, from new average local pressure.
display.str(string("Alt:")) ' Print header Altitude:....
display.str(alt.formatn(a, alt#TO_FEET,8)) ' Print altitude in feet
t := alt.current_temp ' Get the current temperature.
display.str(string("Temp:")) ' Print header Temp:.....
display.str(alt.formatn(t, alt#TO_DEGF,8)) ' Print temperature in Farenheit
display.tx(13) ' Line feed
repeat
altitude:=number.FloatToString(alt#TO_FEET)
if altitude>7201
display.tx(212)
display.tx(220)