Presentation is loading. Please wait.

Presentation is loading. Please wait.

MECH 400 Adam Schuetze:

Similar presentations


Presentation on theme: "MECH 400 Adam Schuetze:"— Presentation transcript:

1 MECH 400 Adam Schuetze: adamschuetze@link2exchange.com

2 Outline for today Motor control with a Pololu MD03A Solenoid control with a MOSFET Digital input hardware Pressure sensor acquisition with a SenSym ASDX Sequential versus event driven controller

3 Motor control with a Pololu MD03A Encapsulate with oUserClass object: oUserClass Motor = New oUserClass(“MD03A.osc”); Create an interface to access motor functions Motor.cw(127); Motor.ccw(127); Motor.stop; Hide technical details inside the object oPWM and oDio1 objects

4 Motor control with a Pololu MD03A MD03A.osc oPWM pwm = New oPWM; oDIO1 inA = New oDIO1; oDIO1 inB = New oDIO1; sub void Config(bit motor_num){ ooPIC.PullUP = cvTrue; pwm.Operate = cvOff; pwm.IOLine = motor_num; pwm.DutyCycle = 0; pwm.PreScale = 2; pwm.Period = 255; if (motor_num == 0){ inA.IOLine = 26; inB.IOLine = 27; } else { inA.IOLine = 24; inA.IOLine = 25; } inA.Direction = cvOutput; inA.State = cvOff; inB.Direction = cvOutput; inB.State = cvOff; pwm.Operate = cvOn; } sub void stop(void){ inA.State = cvOff; inB.State = cvOff; pwm.DutyCycle = 0; } sub void cw(byte speed){ inA.State = cvOn; inB.State = cvOff; pwm.DutyCycle = speed; } sub void ccw(byte speed){ inA.State = cvOff; inB.State = cvOn; pwm.DutyCycle = speed; }

5 Motor control with a Pololu MD03A

6 oUserClass Motor = New oUserClass("MD03A.osc"); const FWD_SPEED = 127; const REV_SPEED = 127; const FWD_BUTTON = 5; const REV_BUTTON = 6; const STOP_BUTTON = 7; const MOTOR_PORT = 0; oButton ForwardButton = New oButton; oButton ReverseButton = New oButton; oButton StopButton = New oButton; oWire ForwardWire = New oWire; oWire ReverseWire = New oWire; oWire StopWire = New oWire; oEvent Forward = New oEvent; oEvent Reverse = New oEvent; oEvent Stop = New oEvent; Sub void Forward_CODE(void){ Motor.cw(FWD_SPEED); } Sub void Reverse_CODE(void){ Motor.ccw(REV_SPEED); } Sub void Stop_CODE(void){ Motor.stop; } sub void main(void){ OOPIc.Delay = 1000; Motor.Config(MOTOR_PORT); ForwardButton.IOLine = FWD_BUTTON; ReverseButton.IOLine = REV_BUTTON; StopButton.IOLine = STOP_BUTTON; ForwardWire.Input.Link(ForwardButton); ForwardWire.Output.Link(Forward.Operate); ReverseWire.Input.Link(ReverseButton); ReverseWire.Output.Link(Reverse.Operate); StopWire.Input.Link(StopButton); StopWire.Output.Link(Stop.Operate); ForwardWire.Operate = cvTrue; ReverseWire.Operate = cvTrue; StopWire.Operate = cvTrue; }

7 Solenoid control with a MOSFET To drive a solenoid with logic-level power, you can use an n-channel logic level MOSFET When digital output pin is high, gate is saturated

8 Solenoid control with a MOSFET Encapsulate with oUserClass object: oUserClass Valve = New oUserClass(“Solenoid.osc”); Create an interface to access solenoid functions Valve.Open; Valve.Closed; Valve.Invert; Hide technical details inside the object oDio1 object

9 Solenoid control with a MOSFET Solenoid.osc oDio1 Coil = New oDio1; sub void main(void){ } sub void Config(Byte IOPort){ Coil.IOLine = IOPort; Coil.Value = 0; Coil.Direction = cvOutput; } sub void Open(void){ Coil.Set; } sub void Closed(void){ Coil.Clear; } sub void Invert(void){ Coil.Invert; }

10 Digital input hardware Pull-up resistor circuit Size resistor to limit current into signal pin to ~1 mA When circuit is open, signal reads 5V When circuit is closed, signal reads 0V

11 Digital input hardware Encapsulate with oUserClass object: oUserClass LimitSwitch = New oUserClass(“DigIn.osc”); Create an interface to access functions LimitSwitch.Config(); oByte State = New oByte; State = LimitSwitch.State; Hide technical details inside the object oDio1 object

12 Digital Input Hardware DigIn.osc oDio1 Hardware_Object = New oDio1; sub void main(void){ } sub void Config(Byte IOPort){ Hardware_Object.IOLine = IOPort; Hardware_Object.Value = 0; Hardware_Objectl.Direction = cvInput; } function Bit State(void){ State=Hardware_Object.Value; }

13 Pressure sensor acquisition with a SenSym ASDX Analog device with three conductors: +Vs (power to the device) Vout (signal from the device) GND Manufacturer specifies V/psi Calibration is useful to confirm response Use oA2D10 object Other analog input devices can be treated the same

14 Pressure sensor acquisition with a SenSym ASDX Encapsulate with oUserClass object: oUserClass Depth_Sensor = New oUserClass(“SenSym.osc”); Create an interface to access solenoid functions oWord TheDepth = New oWord; TheDepth = DepthSensor.Depth Hide technical details inside the object oA2D10 object

15 Pressure sensor acquisition with a SenSym ASDX SenSym.osc oA2D10 PressureSensor = New oA2D10; sub void Config(Byte IOPort){ PressureSensor.IOLine = IOPort; PressureSensor.Operate = cvTrue; } //Returns depth in centimeters function Word DepthCM(void){ Word Signal; Signal = PressureSensor.Value; if (Signal < 102) {Signal = 102;}; DepthCM = ((Signal*20 - 2040)*10)/153; } function Word Voltage(void){ Voltage = PressureSensor.Value; }

16 Pressure sensor acquisition with a SenSym ASDX oUserClass DepthSensor = New oUserClass("SenSym.osc"); oWord TheDepth = New oWord; oWord TheSignal = New oWord; sub void main(void){ DepthSensor.Config(4); while (1){ TheDepth.Value = DepthSensor.DepthCM; TheSignal.Value = DepthSensor.Voltage; }

17 Sequential versus event driven controller sequential control scheme if and while loops state machines VERSUS Event driven virtual circuits oWire, oEvent, oCompare

18 Summary of today Motor control with a Pololu MD03A Solenoid control with a MOSFET Digital input hardware Pressure sensor acquisition with a SenSym ASDX Sequential versus event driven controller


Download ppt "MECH 400 Adam Schuetze:"

Similar presentations


Ads by Google