How to measure Radio controller receiver pulse

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
LEE
Posts: 5
Joined: Sat Nov 14, 2009 1:22 pm
Location: Malaysia,

How to measure Radio controller receiver pulse

Post by LEE »

How to measure radio controller receive pulse 1 msec to 2 msec repeated 20msec delay? Anyone, using flow code 4 (PIC) decode the pulse and print at E-blocks LCD or drive a simple stepper motor.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to measure Radio controller receiver pulse

Post by Benj »

Hello Lee

What target and clock frequency did you have in mind? This should be fairly simple so I will put together a basic example for you.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: How to measure Radio controller receiver pulse

Post by Sean »

Your program seems to need to do perform several functions in addition to the pulse measurement. If this is the case, you will probably need to use interrupts and some internal hardware assistance to maintain any degree of accuracy.

The features available to you will depend on the chip you are using as your target device. The CCP modules attached to some of the timers can be very useful for this purpose, as can multiple INT pins.

LEE
Posts: 5
Joined: Sat Nov 14, 2009 1:22 pm
Location: Malaysia,

Re: How to measure Radio controller receiver pulse

Post by LEE »

the clock speed at 4Mhz, as standard speed

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: How to measure Radio controller receiver pulse

Post by Benj »

Hello Lee

What target device are you gointo be using?

Also are you using a crystal or using the internal oscillator?

The internal oscillator will work but will not give you very good accuracy.

LEE
Posts: 5
Joined: Sat Nov 14, 2009 1:22 pm
Location: Malaysia,

Re: How to measure Radio controller receiver pulse

Post by LEE »

External 4Mhz Xtal, as long It can print out data 0 to 255 on E-Blocks LCD will be OK. The data enought to comunicate with the 1Hpower Yaskawa industrial 220V servo drive and motor. Actually, it like an RC servo but, is a big servo. I can use a touch screen /PLC direct to control the 1Hpower servo motor, It will take more than 5 PLC I/O (very tedious to write the PLC function) . If I make decoder(PIC) save a lot of work and prevent copycat.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: How to measure Radio controller receiver pulse

Post by medelec35 »

Hiya Lee.
Target Device = microcontroller you are using, e.g 16F88
Martin

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: How to measure Radio controller receiver pulse

Post by Sean »

Hello Lee,
I have used Yaskawa servos in the past (SGDA series). I assume you are configuring the drive for one of the digital step input options and expect it to follow the input servo signal via the PIC.
If you can let us know which PIC device you are using, and any other details you are willing to tell us about the project, we should be able to help.

LEE
Posts: 5
Joined: Sat Nov 14, 2009 1:22 pm
Location: Malaysia,

Re: How to measure Radio controller receiver pulse

Post by LEE »

Hello sean,

Yes, you are right, I let the servo drive detect the pulse (program the drive close loop). the target device PIC 16F84 or 16F88 will be alright. the porpose of this project I am taking, is wood cutting machine. I can progam the data angle 10 to 120 degree from a touch screen to the PLC produce the 20msec delay pulse and one wire to the decoder (PIC 16F84 or 16F88) . The decoder will be able send signal to the servo drive/motor to rotate the circular saw at the request angle..I found this method to control servo motor intresting, can control few servo motor inside the 20msec delay as long the PLC transistor I/O fast enought. As same to the RC heli 8 chanel I own ( I am old now, not much flight the Heli, bussy for my business in industry machine).

this project is a wood working machine, making circular coffe table (finger joint rubber wood). as the coffe table diameter got biger, so do the angle joint!

this is my first time joint this forum some of the technical word still new to me.

thank for the help.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: How to measure Radio controller receiver pulse

Post by Sean »

The 16F88 will be the better option for this project.
We will post some pulse measuring code on the forum in the next day or two.
The display and stepper functions should be supported by existing Flowcode components.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: How to measure Radio controller receiver pulse

Post by Sean »

Hello Lee,

Here is a PIC16F88 test program that measures the duration of a pulse.
PulseTimer2.fcf
(13 KiB) Downloaded 654 times
It relies on the fact that the 16F88 is using a 4MHz xtal. This allows TMR1 to be clocked at 1MHz - providing 1us resolution.

The system uses the CCP1 module attached to TMR1 to perform the pulse measurement and generate interrupts when pulse edges are detected.

The CCP1 module is initialized to capture a positive edge on the CCP1 pin (RB0). This generates an interrupt that causes TMR1 to start running, and the CCP1 module capture to be swapped to the negative edge.

When a negative edge is detected, the CCP1 registers contain the TMR1 value (number of microseconds since the positive edge). This value is used to update the PulseWidth variable. The capture is also swapped back to positive, and TMR1 is stopped and cleared.

This system can measure pulses upto around 32ms at 1us resolution.

The value returned in the PulseWidth variable is consistantly low by 30 counts (30us). This is due to the interrupt response time. The program compensates for this error when using the value.

Simple division and subtraction operations are used to remove the 1ms servo pulse offset, and scale the result to the required range:
1ms servo pulse = 0
2ms servo pulse = 250

These ranges and values can be changed, if required, using simple calculations.

The value is displayed on an EB-005 LCD E-Block. The use of the RB0 pin as the CCP1 input means that the EB-005 can not be used with its default connection settings. The Flowcode LCD component and EB-005 board are both configured to use connections RB1 to RB6 (EB-005 jumper links moved to the PATCH position and wire links used to connect the appropriate pins).

This is only a test/demonstration program. It will require further development to meet your application requirements (especially when controlling powerful machinery), including protection against false measurements etc.

LEE
Posts: 5
Joined: Sat Nov 14, 2009 1:22 pm
Location: Malaysia,

Re: How to measure Radio controller receiver pulse

Post by LEE »

Hello sean,

Sercurity and emergency switch is build in hard wiring and PLC ladder program in the machine. Thanks for the flow code program, I will further expend for my machine.

In future, how can I contribute some of my flow code project that I have done, in detail, picture to this forums ? Please let me know.
Sorry for some delay reply to this forums, I just came back form Taiwan and China, business trip.
Thanks

Post Reply