Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Hi,
I've just tried RB0 and RB1 on an oscilloscope and there's nothing at RB0 (T0) and a signal as expected at RB1 (T1)

J, could you add a SERVO3 T2 please?
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Show first the exact code from
On high interrupt
Hi J,
On High Interrupt
Save System

PIR1.TMR1IF = 0 'clear the TMR1 IF flag

T1CON.TMR1ON = 0

If servo = 2 Then
servo = 0
PORTB.0 = 1
t1word = 65535 - t0
TMR1H = t1word.HB
TMR1L = t1word.LB
Goto rtn
Endif

If servo = 0 Then
PORTB.0 = 0
PORTB.1 = 1
t1word = 65535 - t1
TMR1H = t1word.HB
TMR1L = t1word.LB
Endif

If servo = 1 Then
PORTB.1 = 0
t1word = 65535 - t2
TMR1H = t1word.HB
TMR1L = t1word.LB
Endif

servo = servo + 1
rtn:
T1CON.TMR1ON = 1
Resume

C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
hi C.
This is the version I have been using for the demo's, needs extending for 6 timings
As jjw is helping, I will not post as well, it will cause confusion.
E

strbase = "1250,1500,1750,2000"
msg1 = strbase
Call strs2hex2(msg1)
idle_loop:
Goto idle_loop
End

'parse msg string into 4, Tmr1 count Up values
Proc strs2hex2(arg1 As String)

st0 = MidStr(arg1, 1, 4)
st1 = MidStr(arg1, 6, 4)
st2 = MidStr(arg1, 11, 4)
st3 = MidStr(arg1, 16, 4)

wt0 = StrValW(st0)
wt1 = StrValW(st1)
wt2 = StrValW(st2)
wt3 = StrValW(st3)

wt0 = 65535 - wt0 ''' wt0= NOT wt0 is the same as 65535 -wt0
wt1 = 65535 - wt1
wt2 = 65535 - wt2
wt3 = 65535 - wt3

'the wt is the TMR1 load value
Hserout #wt0, ",", #wt1, ",", #wt2, ",", #wt3, CrLf
End Proc
Hi E,
It looks good.
Hopefully, I will soon be adding the get_mess section, for gleaning the HSERIN message where it will fit nicely.
C.
 

jjw

Joined Dec 24, 2013
823
Hi J,
All of my replies since #127 have been using that CODE.
After I found T0 didn't work, I added a WAIT only to check the SERVO is still working, and to show you, how near #127 CODE is to working.
When reading about SERVOS, I have seen reference to a 'start' signal for SERVO control I've also tried a WAIT before the T0 TMR1 INTERRUPT (No worky)
C.
In #127 there is a start code before the main loop:
Code:
Servo = 2
t1word = 65534
TIMR1H = t1word.HB
TIMR1L = t1word.LB
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Hi J,
I added a third SERVO here:
Please check the program.

Now neither T0 or T1 is working, but there is a 1500uS square wave at SERVO3 T2.

C
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi J,
I added a third SERVO here:
Please check the program.

Now neither T0 or T1 is working, but there is a 1500uS square wave at SERVO3 T2.

C
It looks ok.
I will try it later in simulator.
Edit: no need if it works in your simulator.
 
Last edited:

jjw

Joined Dec 24, 2013
823
Do you have the servo specs?
Input current, voltage?
Current drawn by the servo?
It might be some hardware problem.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Hi,
I just tried a 1x SERVO program and now SERVO1 T0 moves, but I can't get it to move CW/CCW it just moves to one end.
I recall that some SERVOs need a trigger signal, which I'll look into.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Do you have the servo specs?
Input current, voltage?
Current drawn by the servo?
It might be some hardware problem.
Hi J,
E, also asked for them, so I'll see what I can find.
Here is a link: http://pcbheaven.com/wikipages/How_RC_Servos_Works/
I'll look for more details.

I've been using 5V for the 5V SERVOs, with 3V signals (Testing)
When a SERVO works, it shows on the oscilloscope, when a SERVO doesn't work, it also shows on the oscilloscope.

Note: The 'Flowchart' on #126 shows an alternative timing to the one we're working on, it may be worth a try?
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
Do you have the type of the servo, manufacturer etc.
Maybe something can be found on the net.
Where did you buy them?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Do you have the type of the servo, manufacturer etc.
Maybe something can be found on the net.
Where did you buy them?
Hi J,
Any analog SERVO will do (e,g, Futaba 3003) I will be using motor controllers mostly so not actually SERVOs.

I just connected an RC receiver with 2x outputs with a 2x channel transmitter. On the oscilloscope, the signal is just the same as the PCB.

One thing I noticed when I added a third SERVO so trying 1 then 2 then 3, is I only got a signal at the highest number, so if I had 3x SERVOS then I only got a signal at RB2 (SERVO3). It's not out of the question that it's an Oshonsoft problem.
C.
 

jjw

Joined Dec 24, 2013
823
I don't quite understand.
Are you using servos or not?
Why you need motor controllers?

Servos may need a lot of current.
What is the max. current from your 5V supply.

I found this from Sparkfun:

Troubleshooting
Regardless of how you’re driving it, servos sometimes require a little extra attention to get working. Here are a few troubleshooting tips.

  • Even unloaded servos can draw quite a bit of power. For full strength, you should be sure that your power supply can provide at least one Ampere per servo.
    • When the power supply isn’t up to the task, servos behave poorly. They’ll move more slowly than a properly powered servo.
    • Underpowered servos are prone to hunting, where they don’t move cleanly to the desired position, but instead move back and forth near that position. They might also audibly hum, or repeatedly reset.
    • In some circumstances, when the servos and processor are running off the same power supply, the servos can draw so much current (or put so much noise on the line) that it may cause your processor to reset or misbehave. The simplest solution to this issue is to run your processor and servos off separate power supplies (but be sure to have a common ground between them). More complex solutions involve power supply noise filtering techniques; Google for advice.
    • Powering your project via USB is only suitable for the smallest of servo motors. A medium servo easily exceeds the 100 mA available from a USB port.
    • If your power LEDs flicker when you try to actuate the servo, you’re in risky territory!
  • Servos have a maximum speed. If your servo is acting erratically, you may be trying to get it to switch from one position to another too quickly. Pausing between your commands gives the servo time to react.
  • As mentioned in the Range Constraints section, some servos have different ranges of movement.
    • When servos are driven past their end stops, they might hum, or grind their gears. Be careful if your servo starts clicking, a sign that the gears are binding.
    • If this will affect your project, look for a servo that is specified to provide 180° of rotation. Also, note that the Servo library’s attach() command allows you to fine-tune each servo’s min and max position, to help avoid driving it beyond the limits.
 

jjw

Joined Dec 24, 2013
823
Hi J,
Any analog SERVO will do (e,g, Futaba 3003) I will be using motor controllers mostly so not actually SERVOs.

I just connected an RC receiver with 2x outputs with a 2x channel transmitter. On the oscilloscope, the signal is just the same as the PCB.

One thing I noticed when I added a third SERVO so trying 1 then 2 then 3, is I only got a signal at the highest number, so if I had 3x SERVOS then I only got a signal at RB2 (SERVO3). It's not out of the question that it's an Oshonsoft problem.
C.
Do you get the 1-2ms pulses from all pins rb0, rb1, rb2, if servos are disconnected?
 
Top