Interrupts conflicting with servo control

sailgene

Member
I hate to admit this, but I'm stumped after working on an ROV project using Serial Communication and Brushless Motors for propulsion. I'm using Servo and Servopos commands which work fine before employing Serial Communication. Part of the process requires that 2 motors work in parallel.

I've finally found out that interrupts can/will interfere with Servo commands (something to do with timing). In finding this out, it's become my understanding that a Servo Controller Board, separate from my main processor, can solve this problem. But I could not find any examples of code where the main processor would receive a command (Serin), including an analog reading (for speed), and then pass this command onto the Servo Control processor which would then control the Servos without any timing issues. If I2C communication is involved between the 2 processors, how does the Servo Control processor avoid any timing issues - or is that a stupid question?

By the way, I've tried using the "Start0, Start1, etc." heading for parallel duties and I've tried using PWM, all to no effect. So I want to purchase a Servo Control board after I'm confident that this addition will solve the problem.

Thanks for any help.
 
I'm using Servo and Servopos commands which work fine before employing Serial Communication.
I've finally found out that interrupts can/will interfere with Servo commands

Sailgene,

What you describe here is a well known issue, but it is the other way around from what you seem to describe:
  • The SERVO command uses a hardware interrupt.
  • The SERIN command is implemented using bit-banging in software and the hardware interrupts are disabled during SERIN opertion.
So it is the SERIN command that is causing the problems with the SERVO command.

My first suggestion is to try using HSERIN instead of SERIN.
  • The HSERIN command uses a seperate hardware module in the PICAXE chip. It can receive a serial byte in parallel with the PICAXE BASIC commands being executed and does not have the same impact that the SERIN command does.
  • HSERIN is available on both the M2 & X2 chips but is more powerful (and much more convenient to use) on the X2 chips.
What chip are you using?

My second suggestion is to re-visit using PWM.
It might be possible to use the PWMOUT command, provided that your servos can accept updates at a period much higher than the standard 20ms , as described by MikeyBoo in posts #8 & #11 of this thread.

I've never used one of the Servo Control Boards. I imagine that they might use a separate I2C hardware module on the chip to avoid the same impact that bit-banged I2C in software could have on the Servo outputs, but you would have to buy one to test this out yourself.

The best way the forum can help you is if you post the code you are using that has the problem.
  • This allows us to suggest code changes.
  • We may be able to test our suggestions before posting the code changes.
  • We can check to see if our suggestions might clash with other things, like your use of multiple starts.
 
Thank you, Flenser. I have several issues going on. I'm using 18M2 chips, but both are already hard-wired to PCB's using RS485 communication. This eliminates the use of HSERIN as my input pin which drives the ROV is C.5. Also, I've messed around with PWM and I can't seem to find the right coding to initialize the ESC's which require a 1.47 MS pulse. Another problem - I have 4 motors with 2 pairs each requiring parallel operation. PWM would only give me 2 pins (B.3 & B.6) to work with and I'd need 4.

My apologies for the formatting of the following code but I couldn't figure out how to add it without simply copying and pasting. I can resend this if anyone can help with adding the code properly. Both sets of codes are limited to the first command of driving the ROV forward with 4 speeds. All other code that isn't included is pretty similar with a few variations for turning the vehicle.

The main questions is, can the "Servopos b.6 and b.7" commands be somehow interfering with each other? Both ESC's seem to initialize properly but once a FWD command is issued, I get inconsistent reactions - only one motor running, one motor turning slowly without any commands, etc. Does any of this code look suspicious? Thanks!

'18M2 CHIP
'TOPSIDE CONTROL SOFTWARE
INIT:
PAUSE 1000
SETFREQ M4
DISCONNECT
LET DIRSB = %00000000 'SET B0 THROUGH B7 AS INTPUTS ("0" = INPUT)
LET DIRSC = %00001000 'SET C0 THROUGH C7 AS INPUTS ("0" = INPUT) 'ACTION TO OPERATE CAMERA
SYMBOL SLAVE = B10
SYMBOL ACTION = B11
SYMBOL SPEED = B0 'PORT MOTOR
SYMBOL POSITION1 = B3 'B4 IS SERVO SETTING
SYMBOL LEVEL = B4
LET B0 = SPEED MIN 75
LET B0 = SPEED MAX 225
LOW C.3
PAUSE 1000

MAIN:
LET SLAVE = 0
LET ACTION = 0
LET SPEED = 0
PAUSE 50
HIGH C.3
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)
PAUSE 5
IF PINB.0 = 1 THEN FWD
IF PINB.1 = 1 THEN RV
IF PINB.2 = 1 THEN RT
IF PINB.3 = 1 THEN LT
IF PINC.4 = 1 THEN DIVE
IF PINC.5 = 1 THEN SURF
IF PINB.7 = 1 THEN PANUP
IF PINB.6 = 1 THEN PANDN
'IF PINC.1 = 1 THEN OPCLAW
'IF PINC.0 = 1 THEN CLCLAW
IF PINC.7 = 1 THEN WTDROP
IF PINC.6 = 1 THEN LTONOFF
GOTO MAIN

FWD:
LET SLAVE = 2
LET ACTION = 1
READADC C.2, SPEED
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)
PAUSE 40
IF PINB.0 = 1 THEN FWD
LOW C.3
PAUSE 10
GOTO MAIN
----------------------------------------------------------------------------------------------

'SLAVE #2
'18M2 CHIP
'BOTTOMSIDE CONTROL
'MOTOR, LIGHT, CLAW, WEIGHT AND FLAG CONTROL PCB

INIT:
PAUSE 1000
SETFREQ M4
SERVO B.4, 150 'INITIALIZE ESC'S FOR BRUSHLESS MOTORS
SERVO B.5, 150 '150 IS NEUTRAL FOR B.4 & B.5, 147 FOR B.6 AND B.7
SERVO B.6, 147
SERVO B.7, 147
PAUSE 5000
SYMBOL COMMAND = B1
SYMBOL SPEED = B2
SYMBOL SLAVE = B3
SYMBOL SPEED1 = B4
SYMBOL NEUTRAL = B8 'SET UP THE NEUTRAL "THROTTLE" FOR PROPULSION MOTORS
SYMBOL HOVER = B9 'SAME FOR DIVE/SURFACE MOTORS
LET B8 = 147
LET B9 = 150
PAUSE 4000
SETINT %00100000,%00100000 'SET IT UP THAT IF PIN C.5 GOES HIGH, AN INTERRUPT OCCURS
PAUSE 10

MAIN:
PAUSE 10
GOTO MAIN

INTERRUPT:
SERIN C.5, T4800_4, SLAVE, COMMAND, SPEED 'SLAVE #2 IS A QUALIFIER FOR THIS CHIP
IF SLAVE = 2 AND COMMAND = 1 THEN FWD
IF SLAVE = 2 AND COMMAND = 2 THEN REVER
IF SLAVE = 2 AND COMMAND = 3 THEN RT
IF SLAVE = 2 AND COMMAND = 4 THEN LT
IF SLAVE = 2 AND COMMAND = 5 THEN DIVE
IF SLAVE = 2 AND COMMAND = 6 THEN SURF
IF SLAVE = 2 AND COMMAND = 15 THEN LIGHTON
IF SLAVE = 2 AND COMMAND = 16 THEN LIGHTOFF
SETINT %00100000,%00100000
RETURN

FWD:
SERIN C.5, T4800_4, SLAVE, COMMAND, SPEED 'THIS SETUP IS FOR A 4-SPEED SITUATION VS. INFINITE ANALOG CONTROL
PAUSE 150
IF SPEED >= 75 AND SPEED < 100 THEN
SPEED = 155
GOTO FWD1
ENDIF
IF SPEED >= 100 AND SPEED < 125 THEN
SPEED = 165
GOTO FWD2
ENDIF
IF SPEED >= 125 AND SPEED < 150 THEN
SPEED = 175
GOTO FWD3
ENDIF
IF SPEED >= 150 THEN
SPEED = 185
GOTO FWD4
ENDIF
FWD1:
SERVOPOS B.6, SPEED
SERVOPOS B.7, SPEED
IF COMMAND = 1 THEN FWD
SERVOPOS B.6, NEUTRAL
SERVOPOS B.7, NEUTRAL
SETINT %00100000,%00100000
RETURN
FWD2:
SERVOPOS B.6, SPEED
SERVOPOS B.7, SPEED
IF COMMAND = 1 THEN FWD
SERVOPOS B.6, NEUTRAL
SERVOPOS B.7, NEUTRAL
SETINT %00100000,%00100000
RETURN
FWD3:
SERVOPOS B.6, SPEED
SERVOPOS B.7, SPEED
IF COMMAND = 1 THEN FWD
SERVOPOS B.6, NEUTRAL
SERVOPOS B.7, NEUTRAL
SETINT %00100000,%00100000
RETURN
FWD4:
SERVOPOS B.6, SPEED
SERVOPOS B.7, SPEED
IF COMMAND = 1 THEN FWD
SERVOPOS B.6, NEUTRAL
SERVOPOS B.7, NEUTRAL
SETINT %00100000,%00100000
RETURN
 
Both ESC's seem to initialize properly but once a FWD command is issued,

Sailgene,
The fact that you get inconsistent results indicates to me that the data the slave is receiving is likely corrupt.

And, after a couple of false starts, I've spotted an issue with the TOPSIDE CONTROL SOFTWARE program that is likely contributing to this problem.

The code does not always signal the slave that a new serial command is coming.

This code repeatedly sends updated FWD commands so long as PINB.0 is high BUT there is no explicit LOW to HIGH transition to trigger the slave INTERRUPT routine.
Code:
FWD:
LET SLAVE = 2
LET ACTION = 1
READADC C.2, SPEED
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)
PAUSE 40
IF PINB.0 = 1 THEN FWD

The slave is still configured to call the INTERRUPT routine when there is a LOW to HIGH transition on the receiving pin and this means that it will be the first bit with a value of 0 in the data byte that will be trigger the INTERRUPT after which the SERIN command will wait for the first following bit with a value of 1, which it will treat as the start bit. SERIN will then build the received byte taking 8 samples 1 bit apart which will be the wrong values.

My suggestion is to change the code to explicitly send a pulse HIGH-LOW-HIGH to trigger the slave INTERRUPT before each SEROUT command.

Here is a modified version of that section of the TOPSIDE CONTROL SOFTWARE program you posted where I have moved around the HIGH & LOW C.3 commands for you to test:
- I've taken the LOW C.3 out of the INIT section and put it before the HIGH C.3 in the main section
- I've removed the LOW C.3 and PAUSE from the end of the REV section and added an explicit LOW C.3 & HIGH C.3 pulse before the SEROUT in this section.
- I have not changed any other logic.
Code:
'18M2 CHIP
'TOPSIDE CONTROL SOFTWARE
INIT:
PAUSE 1000
SETFREQ M4
DISCONNECT
LET DIRSB = %00000000 'SET B0 THROUGH B7 AS INTPUTS ("0" = INPUT)
LET DIRSC = %00001000 'SET C0 THROUGH C7 AS INPUTS ("0" = INPUT) 'ACTION TO OPERATE CAMERA
SYMBOL SLAVE = B10
SYMBOL ACTION = B11
SYMBOL SPEED = B0 'PORT MOTOR
SYMBOL POSITION1 = B3 'B4 IS SERVO SETTING
SYMBOL LEVEL = B4
LET B0 = SPEED MIN 75
LET B0 = SPEED MAX 225
PAUSE 1000

MAIN:
LET SLAVE = 0
LET ACTION = 0
LET SPEED = 0
PAUSE 50
LOW C.3    ; Send the pulse to trigger the SLAVE INTERRUPT
HIGH C.3    ; leaving the serial like idling HIGH for SEROUT
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)        ; Send the command leaving the serial line HIGH
PAUSE 5
IF PINB.0 = 1 THEN FWD
IF PINB.1 = 1 THEN RV
IF PINB.2 = 1 THEN RT
IF PINB.3 = 1 THEN LT
IF PINC.4 = 1 THEN DIVE
IF PINC.5 = 1 THEN SURF
IF PINB.7 = 1 THEN PANUP
IF PINB.6 = 1 THEN PANDN
'IF PINC.1 = 1 THEN OPCLAW
'IF PINC.0 = 1 THEN CLCLAW
IF PINC.7 = 1 THEN WTDROP
IF PINC.6 = 1 THEN LTONOFF
GOTO MAIN

FWD:
LET SLAVE = 2
LET ACTION = 1
READADC C.2, SPEED
LOW C.3    ; Send the pulse to trigger the  SLAVE INTERRUPT
HIGH C.3    ; Leave the serial like idling HIGH for SEROUT
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)    ; Leaves the serial like idling HIGH
PAUSE 40
IF PINB.0 = 1 THEN FWD
GOTO MAIN
 
Sailgene,
To post code click on the "three dots" icon above the new post to get extra options and click on </>. This will open a dialog box where you can paste in your code. There is no need to re-post your previous code.

Untitled.png
 
Well, after a lot of tweaking, I overcame the serin problem with a strange twist. When I added an insignificant "high" command to an unused pin, followed by the servopos commands, the Esc's/Brushless motors responded perfectly and in sync. I did attempt Flenser's code ideas for the topside serout but "no joy". But I got it working with some other commands. I also switched to the Case/Select system for speed control although I can only change speeds by first stopping to serout. Here is my sample topside and bottomside code that works. And thanks so much to Flenser for your assistance.

Code:
'TOPSIDE:'
INIT:
PAUSE 1000
SETFREQ M4
DISCONNECT
LET DIRSB = %00000000                'SET B0 THROUGH B7 AS INTPUTS ("0" = INPUT)
LET DIRSC = %00001000                'SET C0 THROUGH C7 AS INPUTS ("0" = INPUT)                        'ACTION TO OPERATE CAMERA
SYMBOL SLAVE = B10
SYMBOL ACTION = B11
SYMBOL SPEED = B0                    'PORT MOTOR
SYMBOL POSITION1 = B3                'B4 IS SERVO SETTING
SYMBOL LEVEL = B4
SYMBOL V_LOW = 0
SYMBOL V_MED = 75
SYMBOL V_MEDHIGH = 125
SYMBOL V_HIGH = 175
SYMBOL V_HIGHEST = 225
LET B0 = SPEED MIN 75
LET B0 = SPEED MAX 225
PAUSE 1000           

MAIN:
READADC C.2, SPEED
SEROUT C.3,T4800_4, (0,0, SPEED)
PAUSE 5
IF PINB.0 = 1 THEN FWD1
IF PINB.1 = 1 THEN RV
IF PINB.2 = 1 THEN RT
IF PINB.3 = 1 THEN LT
IF PINC.4 = 1 THEN DIVE
IF PINC.5 = 1 THEN SURF
IF PINB.7 = 1 THEN PANUP
IF PINB.6 = 1 THEN PANDN                   
'IF PINC.1 = 1 THEN OPCLAW
'IF PINC.0 = 1 THEN CLCLAW
IF PINC.7 = 1 THEN WTDROP
IF PINC.6 = 1 THEN LTONOFF
LOW C.3
PAUSE 2
GOTO MAIN

FWD1:
READADC C.2, SPEED
SELECT SPEED
CASE V_LOW TO V_MED
    SPEED = 155
    GOTO FWD
CASE V_MED TO V_MEDHIGH
    SPEED = 165
    GOTO FWD
CASE V_MEDHIGH TO V_HIGH
    SPEED = 175
    GOTO FWD
CASE V_HIGH TO V_HIGHEST
    SPEED = 185
    GOTO FWD
ENDSELECT

FWD:
LET SLAVE = 2
LET ACTION = 1
HIGH C.3
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)
PAUSE 10
IF PINB.0 = 1 THEN FWD   
LOW C.3
PAUSE 2
GOTO MAIN

'SLAVE #2
'18M2 CHIP
'BOTTOMSIDE CONTROL
'MOTOR, LIGHT, CLAW, WEIGHT AND FLAG CONTROL PCB

INIT:
PAUSE 1000
DISCONNECT
SETFREQ M4
PAUSE 1000
SYMBOL COMMAND = B1
SYMBOL SPEED = B2
SYMBOL SLAVE = B3
SYMBOL SPEED1 = B4
SYMBOL NEUTRAL = B8        'SET UP THE NEUTRAL "THROTTLE" FOR PROPULSION MOTORS
SYMBOL HOVER = B9            'SAME FOR DIVE/SURFACE MOTORS
LET B8 = 147
LET B9 = 150
LET B2 = SPEED MIN 75
LET B2 = SPEED MAX 225
'SERVO B.4, HOVER            'INITIALIZE ESC'S FOR BRUSHLESS MOTORS
SERVO B.5, HOVER            '150 IS NEUTRAL FOR B.4 & B.5, 147 FOR B.6 AND B.7
SERVO B.2, NEUTRAL
SERVO B.3, NEUTRAL
PAUSE 3000
SERVOPOS B.2, NEUTRAL
SERVOPOS B.3, NEUTRAL
PAUSE 5000
SERVOPOS B.2, 155
PAUSE 2
SERVOPOS B.3, 155
PAUSE 1000
SERVOPOS B.2, NEUTRAL
SERVOPOS B.3, NEUTRAL
PAUSE 10
PAUSE 10
HIGH B.4
PAUSE 1000
LOW B.4
SETINT %00100000,%00100000    'SET IT UP THAT IF PIN C.5 GOES HIGH, AN INTERRUPT OCCURS
PAUSE 10

MAIN:
PAUSE 10
GOTO MAIN

INTERRUPT:
SERIN C.5, T4800_4, SLAVE, COMMAND, SPEED                    'SLAVE #2 IS A QUALIFIER FOR THIS CHIP
IF SLAVE = 2 AND COMMAND = 1 THEN FWD
IF SLAVE = 2 AND COMMAND = 2 THEN REVER
IF SLAVE = 2 AND COMMAND = 3 THEN RT
IF SLAVE = 2 AND COMMAND = 4 THEN LT
IF SLAVE = 2 AND COMMAND = 5 THEN DIVE
IF SLAVE = 2 AND COMMAND = 6 THEN SURF
IF SLAVE = 2 AND COMMAND = 15 THEN LIGHTON
IF SLAVE = 2 AND COMMAND = 16 THEN LIGHTOFF
SETINT %00100000,%00100000
RETURN

FWD:
PAUSE 2
HIGH C.7
PAUSE 2
LOW C.7
PAUSE 2
SERVOPOS B.2, SPEED
PAUSE 2
SERVOPOS B.3, SPEED
PAUSE 10
SERIN C.5, T4800_4, SLAVE, COMMAND, SPEED
IF COMMAND = 1 THEN FWD
SERVOPOS B.2, NEUTRAL
SERVOPOS B.3, NEUTRAL
PAUSE 10
SETINT %00100000,%00100000
RETURN
 
Well, after a lot of tweaking, I overcame the serin problem
Glad to hear that to got this working.
I can only change speeds by first stopping to serout
That is likely because of this code in the TOPSIDE program:
Code:
FWD:
LET SLAVE = 2
LET ACTION = 1
HIGH C.3
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED)
PAUSE 10
IF PINB.0 = 1 THEN FWD   
LOW C.3
PAUSE 2
GOTO MAIN

So long as PINB.0 = 1 you continually send ACTION=1 commands to SLAVE 2 but you never READADC C.2 in this loop to update SPEED, so all these ACTION=1 commands will send the original speed you set in the FWD1 section.

It looks like you intend the "IF PINB.0 = 1 THEN" statement to jump to FWD1 to get a speed update, not FWD.
 
You're correct. I tried to go back to fwd1 but got erratic motor movement as I adjusted the ADC numbers. Not sure why. I also combined the code to eliminate the additional sub procedure (fwd) but again, got erratic motor movement. Don't know why but it didn't like to see ADC updates being changed in the middle of the program. I might try adding a pause after the Read C.2, Speed command and see if that would clean up the motor action. But at this moment, I'm just relieved that I get those 2 servo commands working together. Thanks again.
 
Problem solved! I embedded the serout code within each select-case routine and added a 100ms pause to the Readadc command. And although I'd initiated with a "speed = speed max 225" argument, I ended up needing to change my highest select-case routine to a maximum 255. Otherwise, when I turned up the ADC to full voltage, the motors stalled and started twitching.

So I'm adding a bit of code to show the new-improved speed control without erratic behavior - slowest speed only. And so once again, Flenser, thanks so much for your quick feedback in the forum. I love Basic coding language as it seems so much more straight-forward than Arduino's stuff.

Code:
INIT:
PAUSE 1000
SETFREQ M4
DISCONNECT
LET DIRSB = %00000000                'SET B0 THROUGH B7 AS INTPUTS ("0" = INPUT)
LET DIRSC = %00001000                'SET C0 THROUGH C7 AS INPUTS ("0" = INPUT)                        'ACTION TO OPERATE CAMERA
SYMBOL SLAVE = B10
SYMBOL ACTION = B11
SYMBOL SPEED = B0                    'PORT MOTOR
SYMBOL SPEED1 = B1
SYMBOL POSITION1 = B3                'B4 IS SERVO SETTING
SYMBOL LEVEL = B4
SYMBOL V_LOW = 0
SYMBOL V_MED = 75
SYMBOL V_MEDHIGH = 125
SYMBOL V_HIGH = 175
SYMBOL V_HIGHEST = 255
LET B0 = SPEED MIN 75
LET B0 = SPEED MAX 225
PAUSE 1000           

MAIN:
READADC C.2, SPEED
SEROUT C.3,T4800_4, (0,0, SPEED, 0)
PAUSE 5
IF PINB.0 = 1 THEN FWD
IF PINB.1 = 1 THEN REV1
IF PINB.2 = 1 THEN RT
IF PINB.3 = 1 THEN LT
IF PINC.4 = 1 THEN DIVE
IF PINC.5 = 1 THEN SURF
IF PINB.7 = 1 THEN PANUP
IF PINB.6 = 1 THEN PANDN                   
'IF PINC.1 = 1 THEN OPCLAW
'IF PINC.0 = 1 THEN CLCLAW
IF PINC.7 = 1 THEN WTDROP
IF PINC.6 = 1 THEN LTONOFF
LOW C.3
PAUSE 2
GOTO MAIN

FWD:
READADC C.2, SPEED
PAUSE 100
SELECT SPEED
    
CASE V_LOW TO V_MED
    SPEED = 155
LET SLAVE = 2
LET ACTION = 1
LET SPEED1 = 3
HIGH C.3
PAUSE 2
SEROUT C.3,T4800_4,(SLAVE, ACTION, SPEED, SPEED1)
PAUSE 10
IF PINB.0 = 1 THEN FWD   
LOW C.3
PAUSE 2
GOTO MAIN
 
Hello,
I'm just testing the sending formatted code option.
I've clicked the three dots, and I only get an option for inline code. Not </>
Where am I failing?
 
I've clicked the three dots, and I only get an option for inline code. Not </>

The >_ inline code option you found in this first 3 dots item:
inlinecode.PNG
will highlight the text you have selected in the middle of a sentence with a grey background, like I've done for this SETFREQ command.

The </> code option you are looking for to put the text into a separate grey panel in you post with the Code: title is under the second 3 dots item:
code.PNG
 
I ended up needing to change my highest select-case routine to a maximum 255. Otherwise, when I turned up the ADC to full voltage, the motors stalled and started twitching.

In general, hobby servos use a pulse width of 1.0 ms for 90° CCW and 2.0 ms for 90° CW with the physical limits and timings of the servo hardware varying between brands and models. If you are interested checkout the Wikipedia article Servo (radio control) for more details and some history of what led to this.

Your ESCs are designed to use the same range of pulse widths as hobby servos so the stalling and twitching behaviour you describe sounds to me like you have discovered how your ESCs behave when you send a pulse width (much) longer than they support.

I suggest you do a web search to find both the max and min valid pulse width you ESCs support and update your code with these.
 
There is no specific support for my particular brand of ESC's (ZMR Bi-Directional) although 1.5 ms is known to be a neutral point and also the timing for initialization. And so, I've just done a lot of tweaking of the Picaxe code to find the "sweet spot" for these ESC's. It also seems that with Interrupts, using Pause commands is a bit tricky in getting the timing right.

I've programmed the same 18M2 chip for ROV work using DC motor drivers/controllers and have had no problems whatsoever. But these ESC's have turned out to be quite the challenge in programming. I like to think I'm going to live longer as long as there's a challenge to solve - and boy, are these ESC's lengthening my life!

Thanks again for all of you time and attention to my inquiries.
 
It also seems that with Interrupts, using Pause commands is a bit tricky in getting the timing right.
From this comment it appears that you are trying to get pause commands to work with interrupts.

Are you aware that pause is one of the commands that will not work as expected in a program that uses interrrupts?

This comment about interrupts from the SETINT command in the online PICAXE manual (which is always more up-to-date than the PDF manual):
"After the interrupt code has executed, program execution continues at the next program line in the main program. In the case of the interrupted pause, wait, play or tune command, any remaining time delay is ignored and the program continues with the next program line."

A workaround for this issue is to use a software loop in place of the pause, like this:
FOR B10=0 TO 1000
NEXT B10

You will need to tune the loops TO value for each pause you want to replace at the CPU frequency that you are using.
 
Sorry for being unclear. My comment about pauses deal specifically within the sub-procedures controlling the ESC's after an interrupt occurs. The servo commands to the ESC's do not seem to work correctly without adding a short pause between each Servopos command (i.e. "Servopos B.2, 185, PAUSE 2, Servopos B.3, 185". This may be related to how the ESC's operate vs. actual Servos. Not sure but the addition of a short pause is inconsequential to the overall operation.
 
Back
Top