PDA

View Full Version : Question PIC/JAL reading pwm from Tx


arcticpixels
Apr 25, 2006, 04:17 PM
Hi

I am quite new to PIC.

Had a 12F675 flashing 4 LEDs in a pattern designed by me :cool:
(Still havent figured why the are different brightness :confused: )

Conclusion so far: JAL seems easy, ASM may be worth the time, but currently I dont feel I have the time to dig in(Next winther maybe...)

Now I have done a little research, and found some nice examples on how to control a servo with a JAL program (Thanks Malc C!) but havent tried i out yet.

What I'm looking for is a way to read the signal from the Tx, and have the PIC outputs set according to the value.

Ex: using an analog channel to control different functions (0% = gear slow down, lights on, 25% gear slow up - ligths still on, 50% landing lights off, -strobes still on, 75% all lights off, 100% cycle a servo to release payload (parachute jumper, waterballon, candy...)

I may find a lot of other applications, just to give an example on what I'm after...

I would like to stay with JAL if possible (or another [free] higher level language with an easy learning curve - C, Pascal, Basic what ever)

If the 12F675 can be used it would be great. I also have a few other PICs:
16F628A and 16LF84A but they are larger and not that sexy.

I guess that what I'm after, is a way to have the pulsewidth timed, and set a variable accordingly.

Regards

Niels

Malc C
Apr 25, 2006, 04:51 PM
I know the principle of how to read the PPM signal, but not how to impliment it in JAL

You could subscribe to the JAL yahoo group jallist@yahoogroups.com and I'm sure someone will give you some help. The starnge thing is that although I have some code in ASM that reads the PPM signals, I too was looking at doing it in JAL using the same chip.

The best way I've been advised is to use tmr1 to count the amount of time the pulse is high. Connect the pulse input to gp4 so that the timer will run when the pulse is high (T1G option). You can then decide if the pulse is long enough by looking at the count value.

You will need to read the counter when the pulse input is low and the timer value is >0. The value should be cleared after its read, ready for the next pulse. I'll have a play and see if I can get it working, initially just to act as a switch if the signal is > 1.5ms, but given my novice status in JAL, don't hold your breath ;)

Malc

EDIT: - I've just put a post on Jallist.. lets see if there is any help ?

xtal
Apr 25, 2006, 06:56 PM
http://www.rcgroups.com/forums/showthread.php?t=475518
[see latest post ]
I just posted this...
the mikro-basic program pidCservo.pbas has interrupt proceedure to capture/compute servo pulse .....
mikro-basic demo version allows 2k program...
also
mikro-c and mickro-pascal available

Malc C
Apr 26, 2006, 07:32 AM
I've downloaded and installed mikrobasic and done a search for the file pidCservo.pbas on the PC and can't find it. Any chance of zipping it up and posting it here, or a URL to the location ?

Cheers

xtal
Apr 26, 2006, 01:54 PM
ok .....I have spotted 1 error about line 85

use the cservo.txt for ref .....

is ---- if PosErr < 0 then
sb IF PrevPosErr < 0 then

I have noted that sometimes when divide longint / 256
negative becomes + ,,,, I don't know if I'm breaking some rule or not

arcticpixels
Apr 26, 2006, 02:58 PM
Malc C

Funny you mentioned it. I too signed up for the jallist yesterday, and wondered why there was just started a discussion about exactly my encitament to join :cool:

Well it seems you have some good leads. I try to follow. I guess soon there will be something to post here i this thread.

I guess my conclusion so far is, that although JAL is simple to make a LED blink, it is difficult to make just a little more advanced tasks with. Maybe it is just the larningcurve...

Am digging in...