Hardware ESC 8xSERVO CONTROL on PIC (Oshonsoft BASIC)

Status
Not open for further replies.
The UART stuff only gets executed if RCIF is one and that gets cleared when RCREG get read. So RCIF does get read.

Hi,
I noticed this in an old program:
----------------------------------
RCON.IPEN = 1 'Must be included when using INTERRUPTS
-----------------------------------
C
Yes, I mentioned this in #383,
One thing that's just occurred to me, there is no longer any interrupt priority used, should it still be "On High Interrupt"?

I'm having problems downloading your GD files. Can you zoom in and tell me if the clock pulse comes slightly before the data line goes low? And, if it does, if Q0 goes high?


Mike.
 
Hi M,
Did you get the Saleue link? Did it work?

Eventually, GPS will be added to this SERVO CODE.
If priority is important, then SERVOs should high, and GPS should be low, but if both can be high that would be better
C
 
I can't download your files.

There is no need for priority on interrupts unless the UART priority is set low so it can stay in there as long as it wishes and the time critical stuff can interrupt it. However, it's much better if the UART ISR is very short (as my earlier code) and then, once a valid sentence is received the main code can take care of it.

BTW, I already have the logic analyser code installed.

Mike.
 
Hi M,
I also tried to download it with a different email address, and couldn't, I'll see if I can get it to work.
Until I get the link working, I can screen shot parts of the analyser screen. Tell me what you need.

Ok, but leave the UART stuff till we've got the SERVO 'shift register' to work.

What's next?
C
 
The double char = RCREG reading is only when you detect an error like overflow. It is used to flush the register, and not save anything.
Otherwise, one always reads RCREG if the RCIF bit is set…
 
The double char = RCREG reading is only when you detect an error like overflow. It is used to flush the register, and not save anything.
Otherwise, one always reads RCREG if the RCIF bit is set…
Hi S,
Ok, thanks.
As this is Usart related, it's better we leave it till later.
I'm good at remembering stuff that's not relevant, and forgetting stuff that is.
C
 
I've now got the logic analyser to work but don't understand it,

What does this mean,


The scale at the top suggests that the 0.235mS is correct but what is the 20mS and the 49.99Hz????
And how can channel 0 be the 8MHz clock, it looks more like 1.5kHz.

Mike.
 
Hi M,
I'm learning the system too. I've speeded up my Version 1 analyser.
I've PMed new ones.
C
 
As you have the hardware, are you able to load a hex file as I could send you the C hex file just to make sure that code actually works? Alternatively, are you able to use MPLABX (spit, spit) with an appropriate programmer (pickit4 etc.)?

Mike.
 
As you have the hardware, are you able to load a hex file as I could send you the C hex file just to make sure that code actually works? Alternatively, are you able to use MPLABX (spit, spit) with an appropriate programmer (pickit4 etc.)?

Mike.
Hi M,
1st,
Did you receive the email 'subject' faster data?
If so, did it open and show on your analyser?
Could you zoom in and out, and see the timings.

Anything with C is a nogo.
I don't have MPLABX as it's too bloated for my liking.
EDIT: Send the HEX file, I can try it.
C
 
Last edited:
I got the email and new file but it still doesn't make any sense. It is full of "framing errors" - what are these? Is it trying to interpret it as 8 bit data?

As I said, doesn't have to be C but can your system upload a hex file?


Mike.
 
I got the email and new file but it still doesn't make any sense. It is full of "framing errors" - what are these? Is it trying to interpret it as 8 bit data?

As I said, doesn't have to be C but can your system upload a hex file?


Mike.
Hi M,
Yes, I think I can load the HEX file, if you send it. I can try.

Regarding the Framing errors, I may not have the settings correct on the analyser, but from what I can see, the timings look ok.

The analyser is showing what the program on the PIC, is outputting. To me it seems to be working.
C
 
Hi M,
I'm still figuring out the settings on the Analyser, or perhaps my wiring, so the Analyser stuff may show wrong Channels.

Send the Hex.
C
 
Hi,
I had a go at writing some simple SW to help me understand, how the 'shift register' works in practice. It simply switches the CLK and DATA ON/OFF in a series of CODE rows.

As only 3x SERVO inputs have been wired to the analyser, I only see 3.

I wired a SERVO to CH1 and it is working fine, considering it's SW, but there's nothing else INTERFERRING with it, so understandable, and only a test.

The CLK tic is only for a few uS, as has been explained, but seeing is believing

Here is the analyser view.
EDIT: I was glad to see the HW PINs are working.
C
 
Last edited:
That is very promising and proves that the hardware is as expected.

Can you post the code that produced that?

Mike.
 
That is very promising and proves that the hardware is as expected.

Can you post the code that produced that?

Mike.
Hi M,
You'll laugh!
It's not CODE but a quick 'see if it's working'.

If the 1st list is run in a LOOP the SERVO has no jitter.
If you run both, you will see that CH1 is slightly different, this is the beginning of movement, but it looks like 'jitter', as it is backwards and forwards.
C.
-------------------------------------------------------------
Symbol rled = PORTD.7

RC0 = 0
RC2 = 0

Dim ch1 As Word
ch1 = 1000
Dim ch2 As Word
ch2 = 1000
Dim ch3 As Word
ch3 = 1000
Dim ch4 As Word
ch4 = 1000
Dim ch5 As Word
ch5 = 1000
Dim ch6 As Word
ch6 = 1000
Dim ch7 As Word
ch7 = 1000
Dim ch8 As Word
ch8 = 1000

Dim frame As Word
frame = 12000 '20000


WaitMs 1000

main: '\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
'OSCCON = %01110000 '& h70

Toggle rled

ch1 = 1000

RC2 = 1 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch1

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch2

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch3

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch4

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch5

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch6

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch7

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch8

frame = 12000
WaitUs frame

ch1 = 1010 '<<<<<<<<<<<

RC2 = 1 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch1

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch2

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch3

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch4

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch5

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch6

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch7

RC2 = 0 '74HC164 DATA
RC0 = 1 '74HC164 CLK
RC0 = 0
WaitUs ch8

frame = 11990
WaitUs frame
Goto main
End
 
They're working because you wrote the code using RC0 as the clock whereas the hardware needs RC2 to be the clock hence why the other code isn't working.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…