Thanks, Chris. I will check into your class. I’m assuming from your code that it works directly from the FEZ pin and not through the servo 16 board. Is this correct?
@ Chimp, the problem with debugging is that is all appears to be working correctly while stepping through, it is simply that the servo isn’t rotating.
As I said, with a button press, it works just fine, with an IR command received, all of code that should run does run, event the same command is sent to the servo, but the servo doesn’t rotate.
private void DoorSetState(DoorStates doorState) {
switch (DoorState) {
case DoorStates.Closed:
DoorServo.SetServoPosition(8, 20, 90);
break;
case DoorStates.Open:
DoorServo.SetServoPosition(8, 10, 0);
break;
}
DoorState = doorState;
}
This is what is executed regardless of a button press or IR command. In both cases it is run.
The steps are:
- Run program
- Press Button
- Servo16 data light flashes
- Servo rotates
- Press Button
- Servo16 data light flashes
- Servo rotates
- Send IR command
- Servo 16 data light flashes
- Servo doesn’t move
- Press Button
- Servo 16 data light flashes
- Servo doesn’t move
- Press Reset on Servo 16 board
- Servo resets itself to 0 point if necessary
- Press Button
- Servo 16 data light flashes
- Servo rotates
No matter the combination of steps, the debugger always states the commands are being sent to the servo. But as soon as I send an IR command, the servo stops responding.
As I said, debugging is proving difficult because I can’t see beyond the
oc.Set(false, buffer, 0, currentBufferIndex, false);
in the FEZ_Components_Servo16.cs class.
Is there anything I should be looking for?
My main program code is:
public static void Main() {
Program program = new Program();
Thread.Sleep(Timeout.Infinite);
}
public Program() {
OnBoardLED = new FEZ_Components.LED(FEZ_Pin.Digital.LED);
TvRemote = new TiVoReceiver(FEZ_Pin.Digital.Di13);
TvRemote.DataReceived += new TVRemoteReceiver.TVRemoteDataHandler(TvRemote_DataReceived);
MainButton = new FEZ_Components.Button(FEZ_Pin.Interrupt.Di4);
DigitalLED = new FEZ_Components.LED(FEZ_Pin.Digital.Di12);
DoorServo = new FEZ_Components.Servo16(FEZ_Pin.Digital.Di0);
DoorState = DoorStates.Closed;
MainButton.ButtonPressEvent += new FEZ_Components.Button.ButtonPressEventHandler(ButtonPressEvent);
OnBoardLED.TurnOn();
DigitalLED.ShutOff();
}
private void TvRemote_DataReceived(TVRemoteReceiver sender, int command, int address) {
TivoButtons buttonPressed = (TivoButtons)command;
DigitalLED.TurnOn();
if ((TivoButtons)command == TivoButtons.ThumbsUp) {
DoorChangeState();
}
else if ((TivoButtons)command == TivoButtons.ThumbsDown) {
DoorChangeState();
}
DigitalLED.ShutOff();
}
protected TVRemoteReceiver TvRemote;
protected FEZ_Components.LED OnBoardLED;
protected FEZ_Components.Button MainButton;
protected FEZ_Components.LED DigitalLED;
protected FEZ_Components.Servo16 DoorServo;
protected DoorStates DoorState;
protected enum DoorStates { Open, Closed };
private void ButtonPressEvent(FEZ_Pin.Interrupt pin, FEZ_Components.Button.ButtonState state) {
if (state == FEZ_Components.Button.ButtonState.Pressed) {
DigitalLED.TurnOn();
DoorChangeState();
DigitalLED.ShutOff();
}
}
#region DoorState Function
private void DoorSetState(DoorStates doorState) {
switch (DoorState) {
case DoorStates.Closed:
DoorServo.SetServoPosition(8, 20, 90);
break;
case DoorStates.Open:
DoorServo.SetServoPosition(8, 10, 0);
break;
}
DoorState = doorState;
}
private void DoorChangeState() {
switch (DoorState) {
case DoorStates.Closed:
DoorOpen();
break;
case DoorStates.Open:
DoorClose();
break;
}
}
#endregion
Could the IR input on one pin through the receiver be throwing off the communication of the servo16 board through the board’s channel to the servo? Everything else functions properly, the LEDs, etc, but no response from servo.