Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
Looking at the REMOTE program at #756, and noting that I still have to add CODE for control, can anyone guess, how long a MAIN LOOP will take?
I'm wondering if the 5xPWM Channels can be added into the LOOP and work ok.

EDIT: I have tried adding a BREAK into the MAIN LOOP and resitting the SIM CLOCK, but the SIM doesn't 'see' the BREAK again?
Cheers, C.
 
Last edited:

jjw

Joined Dec 24, 2013
823
I checked the calculations in the simulator.
The interrupts were disabled.
BMP280 3.1 ms
Compass 8.6 ms
The conversions string=#single takes a lot of time and I deleted them when simulating.
When you handle only a few messages/second, is it too slow for flight control?
Normal R/C control is 50 times/second.
 

jjw

Joined Dec 24, 2013
823
Hi,
Looking at the REMOTE program at #756, and noting that I still have to add CODE for control, can anyone guess, how long a MAIN LOOP will take?
I'm wondering if the 5xPWM Channels can be added into the LOOP and work ok.

EDIT: I have tried adding a BREAK into the MAIN LOOP and resitting the SIM CLOCK, but the SIM doesn't 'see' the BREAK again?
Cheers, C.
It means that the program does not get back from the loop or it stays there very long?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
I checked the calculations in the simulator.
The interrupts were disabled.
BMP280 3.1 ms
Compass 8.6 ms
The conversions string=#single takes a lot of time and I deleted them when simulating.
When you handle only a few messages/second, is it too slow for flight control?
Normal R/C control is 50 times/second.
Hi J,
Ok.
Am I correct then, that there needs to be a TIMER INTERRUPT at 50/sec? for control, using the DATA gleaned a few/sec, as we can't really change the program much.

I am trying out a separate test program only for PWM with an oscilloscope and a test Tricopter, to see what happens.

EDIT: Just thought! We have a spare PIC on the RECEIVER :) The 18F4431 isn't being used, and at the moment has 2x tracks, between it and the 18LF4620, which could be used/modified. I must have forseen this, as the RECEIVER PCB has 5+1GND connector for PWM :)
Thanks, C.
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi J,
Ok.
Am I correct then, that there needs to be a TIMER INTERRUPT at 50/sec? for control, using the DATA gleaned a few/sec, as we can't really change the program much.

I am trying out a separate test program only for PWM with an oscilloscope and a test Tricopter, to see what happens.

EDIT: Just thought! We have a spare PIC on the RECEIVER :) The 18F4431 isn't being used, and at the moment has 2x tracks, between it and the 18LF4620, which could be used/modified. I must have forseen this, as the RECEIVER PCB has 5+1GND connector for PWM :)
Thanks, C.
Do you use servos which need position control or have also motors which needs pwm?
You have some code from 2018 for servo control :)
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Do you use servos which need position control or have also motors which needs pwm?
You have some code from 2018 for servo control :)
Hi J,
Yes, a Tricopter has 3x motors, and 1x servo.
I need to change my thought processes a bit, by playing with actual motors, to get the feel of what happens, with batteries and wires for a while.
I found some CODE, but only scanned it for now, thanks.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
You have some code from 2018 for servo control :)
Hi J,
I looked through pages of amazing patience from you and E, and followed as much progress as I could before adding all of the later stuff.
Here is the program I picked. I'll have to extract the CONTROL sections, and test them, then add them into the latest program.
NOTE: Previously a member suggested raising the speed of the processor. I haven't done this yet, but you'll notice that this program is at 32MHz.
C
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi, (18F4431 5X CHANNEL OUTPUT)
I've modified the program in #767
Hopefully, it now will PARSE a SERIAL DATA sentence and control 5xChannels
EDITED!
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi, (18F4431 5X SERVO OUTPUT)
I've sripped out as much as I dare of the program in #767, which SIMs ok.
I've now got to get used to it, and figure out how to clean it more.
I notice that it has a READ DATA input, which is handy. If it's possible to SEND SERIAL DATA between two simple PINs then there is a spare track between 18LF4620 and 18F4431, that can be used.
I'll add the extra SERVO when I'm more used to it.
C
You said you have only one servo. The control is for the position ( e.g. 0 to 180 degrees )
PWM is different, e.g. speed of the motor, 0 to 100%
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
You said you have only one servo. The control is for the position ( e.g. 0 to 180 degrees )
PWM is different, e.g. speed of the motor, 0 to 100%
Hi J,
We crossed messages >< :0
As you can see I've updated the program in #767 and edited #768

I'm using Tricopters, that have 3x motors and one RUDDER SERVO.
The signals all look the same. I haven't given it much though until now, but A normal transmitter SENDS a serial signal of all of the Channels in series. This is PPM. At the RECEIVER radio it separates them into Channels, and on my system the channels go through a controller board (KK2) This has a GYRO and an Accelerator, to stabilises the craft. The output of the KK2 feeds the MOTORS and the SERVO. The KK2 must be set-up to work with your craft Tricopter Quadcoter Plane etc first.
I have added an extra Channel, for other contingencies.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I forgot to change the Microcontroller from 18LF4620 to 18F4431, so even though the program in #767 compiles, but it doesn't now I've corrected it to 18F4431??
EDIT: I lowered STRING_MAX_LENGTH to 30, and now it complites.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I rotated a compass module around 360° at 15° to make a graph
Here is the graph:
For me it's very pleasing to be able to see what's happening. You'll notice that the SINE waves are a bit flat, which I think is caused by the Z Z UP and DN READings, being at a different scale, so squashing the graph.

I assume that these numbers need correcting, so that they are evenly above and below the centre line. Aslo the RED and DK BLUE waves don't cross at 180°.
I'll use Magmaster for the correction BIAS, and see what these lines look like then.

EDIT: I removed the Z columns, here's the result:
c.
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
Hi,
I rotated a compass module around 360° at 15° to make a graph
Here is the graph:
For me it's very pleasing to be able to see what's happening. You'll notice that the SINE waves are a bit flat, which I think is caused by the Z Z UP and DN READings, being at a different scale, so squashing the graph.

I assume that these numbers need correcting, so that they are evenly above and below the centre line. Aslo the RED and DK BLUE waves don't cross at 180°.
I'll use Magmaster for the correction BIAS, and see what these lines look like then.

EDIT: I removed the Z columns, here's the result:
c.
Calculate the angles with arctan to see the error.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
I checked the calculations in the simulator.
The interrupts were disabled.
BMP280 3.1 ms
Compass 8.6 ms
The conversions string=#single takes a lot of time and I deleted them when simulating.
When you handle only a few messages/second, is it too slow for flight control?
Normal R/C control is 50 times/second.
Hi J,
I'm a little stuck!
I've added the compass BIAS READINgs into the program, on an 18F4431, as this will able to work on it's own while the MAIN PIC on the REMOTE PCB does all of the rest.
The compass is connected to the MAIN PIC 18LF4620 as you know. How can the compass DATA get sent to the 4431 and be received as fast as needed?
C
 

jjw

Joined Dec 24, 2013
823
Hi J,
I'm a little stuck!
I've added the compass BIAS READINgs into the program, on an 18F4431, as this will able to work on it's own while the MAIN PIC on the REMOTE PCB does all of the rest.
The compass is connected to the MAIN PIC 18LF4620 as you know. How can the compass DATA get sent to the 4431 and be received as fast as needed?
C
How fast is fast enough? SPI takes a few tens of microseconds at most.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
How fast is fast enough? SPI takes a few tens of microseconds at most.
Hi J,
I'm not sure how fast!
If I need to use SPI, then I would have to redesign the REMOTE PCB, and add it. I could probably join some test wires, for tests.
There are 2x other tracks also.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
How fast is fast enough? SPI takes a few tens of microseconds at most.
Hi J, [REMOTE]
I think you meant SEND COMP DATA from 4462 to 4431> process> SEND DEG from 4431 to 4620, is this correct?

I got an idea to move all the READ COMP plus 'self test' and average results, from 4620 and put it all on the 4431, then SEND DEG to 4460, so I tried it in SIM.
I added the COMP CODE over to 4431 and is SIMULATES. The 4431 should have plenty of time.
I'm propogating the 4431 side of the PCB, and I'll add SPI wires for the COMP.
C
 

jjw

Joined Dec 24, 2013
823
I don't know why the data has to be sent between processors.
Can't the compass be connected to the processor whch uses it?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
I don't know why the data has to be sent between processors.
Can't the compass be connected to the processor whch uses it?
Hi J,
I thought there is a problem with timing, when the compas is working with averages.
The average section, receives 250 READings while averaging, and I'm sure I remember a comment that it would need an INTERRUPT at each READ, which would spoil the rest of the main program running.
Correct me if I'm wrong.
C
 
Top