rrTV-PHOTO   New HD TV
HOME   rrTV-PHOTO   GALLERIES   MY GALLERY   HELP-FAQ
myHOME PM pmRR MEMBERS 670 ONLINE 73 EVENTS SEARCH REGISTER  START HERE
 
1 page352 viewsPOST REPLY
Esprit Model . Thunder Power RC . Real Raptors

.
.
CAD - Engineering - Technical > PIC Navigational Lights; Assemby Code wanted / Circuit Design
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Looking for an assembly code / circuit diagram for a scale navigation. The basic circuit will be to program a set of LEDs and then another design to use the signal wire (pulse width) from the RX to turn on/off the nav leds.

I know I can easily purchase one but I am going back in time to when I wished I had learned how to program a 16F84 PIC.

I got my programer, MPLAP / MPAS software and have been plugging away at simple codes flashing an LED.

Any help will be greatly appreciated.


Thanks,

Girard



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-20-2008 01:20 AM
HOMEPAGE  
 
 
PilotDaz
Senior Heliman
Location: Seattle, WA

I write assembly code for the 16F84 and could possibly help you. Is the only PIC task you had in mind to turn the LED's on or off based on a PWM signal? Should be a very small program.

~There are two kinds of heli pilots: those that have crashed, and those who are about to.
03-20-2008 05:37 AM
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Yes, that would be a good starting point.

Can you tell me why this program can't run? No leds light up. I compiled it and ran it on the MPLAP Sim and it compiles OK. Then I run it on the sim and it just toggles / repeat it's self at the command line below:

Wait1 decfsz DelayL
goto Wait1


I am not sure why the subroutine causes it to get stuck. I am self teaching myself this language so bear with me.

Thanks for your help.


Here a program that I am studying in learning about the PIC 16F84 and the Assembly language.







Title "DIY Simple Program"

list P=16F84A
;
; ------------------
; CONFIGURATION FUSE
; ------------------
;
__CONFIG 0x3FFB

;
; The purpose of this program is to make the LEDs
; connected to RB2 RB3 RB4 RB5 and RB6 come on from left to right
; and then go back right to left.
; The flash rate is 500mS
; PORT BITS = LOW = LED ON
; PORT BITS = HIGH = LED OFF
;
STATUS equ 0x03
RP0 equ 0x05
PORTA equ 0x05
PORTB equ 0x06
TRISA equ 0x85
TRISB equ 0x86

DelayL equ 0x0C ; delay register LOW byte
DelayM equ 0x0D ; delay register MID byte
DelayH equ 0x0E ; delay register HIGH byte
;
; -------------
; PROGRAM START
; -------------
;
org 0h ; startup address = 0000


movlw b'00000000'
movwf PORTA ; all PORTA pins = 0
movlw b'11111111'
movwf PORTB ; all PORTB pins = 1
bsf STATUS,RP0 ; set RP0 for RAM page 1
movlw b'00000000' ; all PortA = outputs
movwf TRISA
movlw b'00000000' ; all PortB = outputs
movwf TRISB
bcf STATUS,RP0 ; set RP0 for RAM page 0

MainLoop movlw b'11111011' ; RB2 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11110111' ; RB3 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11101111' ; RB4 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11011111' ; RB5 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'10111111' ; RB6 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11011111' ; RB5 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11101111' ; RB4 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

movlw b'11110111' ; RB3 LED = ON
movwf PORTB
call Delay200 ; execute a 500mS delay

goto MainLoop ; do this loop forever
;
; --------------------------------
; SUBROUTINE: waste time for 200mS
; --------------------------------
;
Delay200 clrf DelayL ; clear DelayL to 0
clrf DelayM ; clear DelayM to 0
movlw 1H ; set DelayH to 3
movwf DelayH
Wait1 decfsz DelayL ; subtract 1 from DelayL
goto Wait1 ; if not 0, goto Wait1
decfsz DelayM ; subtract 1 from DelayM
goto Wait1 ; if not 0, goto Wait1
decfsz DelayH ; subtract 1 from DelayH
goto Wait1 ; if not 0, goto Wait1
return ; finished the delay

end



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-20-2008 02:11 PM
HOMEPAGE  
 
 
wlfk
Veteran
Location: uk

This bit seems fine.

Delay200
clrf DelayL ; clear DelayL to 0
clrf DelayM ; clear DelayM to 0
movlw 1H ; set DelayH to 3 - ? set delayh to 1, surely?!
movlw 1
movwf DelayH
Wait1
decfsz DelayL, f ; subtract 1 from DelayL my compiler gpasm would give me a warning for not specifying to decrement the memory address rather than register w. But it would do the right thing anyway
goto Wait1 ; if not 0, goto Wait1
decfsz DelayM, f ; subtract 1 from DelayM
goto Wait1 ; if not 0, goto Wait1
decfsz DelayH, f ; subtract 1 from DelayH
goto Wait1 ; if not 0, goto Wait1
return ; finished the delay

My personal feeling is that most of your comments are redundant. They're simply explaining what the instructions do, and as you learn to program you won't need them. A problem in this part shouldn't cause an LED to fail to light anyway - if it hangs then the LED will simply stay lit forever.

I would try to 'watch' the values in DelayL and DelayM - they should decrement. The problem is probably simply that this bit will take zillions of cycles on the simulator, which will seem to take forever, but in real life it will execute rather quickly - 3 instructions per loop; 65536 loops - 1/5 second or thereabouts.

Some debate over whether you're wasting time for 200 or 500mS

The rest of the program looks broadly OK to me, though bugs aren't always evident and I don't use the 84 much.

I would tend to add a 'goto $' after I'd tried to light the first LED, then use a voltmeter to check the pin. Are you sure the hardware side of things is working OK?

Personally, if you're using 5 LEDs or fewer, I'd use a 12F629 as you can get away without any external components for the clock.

K

A bit like a kite, but 500 times more expensive
03-20-2008 02:45 PM
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

K,

I got the above code from the DIYK81 programming Kit.

It started out as a simple code lighting a led. Then it goes further to making the led flash using a subroutine and delays.

Both of these codes work when I flashed the 16F84, but the code above does not. The codes are the same only more was added to get the led to light up and down.

As for why 5 leds, the Programing Kit 81 comes with a built in test board with 5 leds.

If I can make this code work, I can learn what I am doing wrong and understand the tutorial for this code.

My goal is write a code for my navigation lights for my Scale Heli using the signal from the Rx and controlled via my Xmiter. This is where you come in 

I’ll do some research on the 12F629 but yes that would be the goal, less components and a simple non-redundant code. For now, I need to self teach myself the language and the Pic using you as the online teacher.

Thanks again for your help.



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-20-2008 07:40 PM
HOMEPAGE  
 
 
wlfk
Veteran
Location: uk

How many lights do you need, and how do you want them to flash?

K

A bit like a kite, but 500 times more expensive
03-20-2008 08:31 PM
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Gee, I haven't decided.

Not that far into my scale project. For now any thing will do. That way I can study the code and modify as I go.

For sure all nav lights will turn on using a channel. On another channel, a continuous light used as a head/spot light.

As for blinking can I define the blink rate on the program for the different bits.

Lets start with 5 leds.



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-20-2008 10:22 PM
HOMEPAGE  
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

K,

I figured out why the above code does not work. Not sure if you are familiar with MPLAB. In MPLAB, when I press ALT and F10 Keys the code does not work.

To make the code work, I have to use Mpasm and output the code to Hex.

I thought that MPLAB will compile the code and output a Hex file.

Ok, now back to studying.



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-21-2008 06:37 AM
HOMEPAGE  
 
 
wlfk
Veteran
Location: uk

I haven't used mplab for a long time - I use gpasm and picp under Linux - but I thought there was a way to call mpasm and program the chips from mplab. I may be wrong on that one.

Everything you've talked about is perfectly do-able. I have a tilt-only camera mount where I control the tilt setting, camera and gyro from a single channel. To change tilt setting I flick the gyro switch quickly up and down; to take a series of pictures I flight the gyro switch up and leave it there. And it does all this whilst sending out a gyro gain signal. One chip. One push switch. One smoothing capacitor. Two resistors and an opto-isolator to protect the camera should the BEC fail.

Presumably you've decided on a scale project? Doesn't that dictate the number/positioning of the lights?

K

A bit like a kite, but 500 times more expensive
03-21-2008 10:39 AM
 
 
Rappy 60
Senior Heliman
Location: Houston, Texas

Try having a look here. I wrote my own code for a PIC 12F629 to fire off a camera shutter based on the PWM signal from the receiver. The code on this site is not mine, but has exactly what you are looking for or can "modify" for your own use. I chose to do my coding different and not rely on a loop to determine the Pulse widths from the receiver, I chose to use an interrupt and 16 bit timer. There are several ways to do this including using a counter and gating it with the Pulse width.

http://homepages.paradise.net.nz/bh.../navlights.html


Dale

Load "*",8,1
03-28-2008 06:35 AM
HOMEPAGE  
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Am I missing some thing here.

Where was I all these years. Information on how to do the same routine or any routine, whatever it is, in many different flavors. I can't even picture how you all THINK or see the logic.

I wish I could go back in time and abroad to further my electronics education. But the reality is I can't. And for that, I would like to send my Sincere Thank You for your contribution and guidance.

I am just waiting for the scale CD and researching the information for this project.

I am curious has to what PIC to use for a project. I only know of the 16F84A because that's what my programmer tut entails. It's still very popular but some say it's out dated.

As for MPLAP, I'm not sure what I am doing wrong, but I think it's how I do a quick build verses a project. Still trying to work out this software.


THANKS



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-28-2008 02:24 PM
HOMEPAGE  
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Rappy 60

http://homepages.paradise.net.nz/bh.../navlights.html

Now that's an idea. Low stick, landing lights on and cabin lights. That never crossed my mind, mixing in the Throttle channel to control the landing lights.

Circuit board design using smd, sweet. Small, compact and easy to manually etch. Well, it will take time with a xacto knife but patience goes a long way.



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-28-2008 02:32 PM
HOMEPAGE  
 
 
wlfk
Veteran
Location: uk

Quote 
Am I missing some thing here.

Where was I all these years. Information on how to do the same routine or any routine, whatever it is, in many different flavors. I can't even picture how you all THINK or see the logic.

I started with Myke Predko's book on programming PICs - it's expensive and the accompanying PCB has lots of faults. But it is very good and has lots of explanations.

Did you ever learn to program desktop computers? I'm sure this helps in terms of 'seeing' algorithms. Microcontrollers are somewhat different - more akin to programming assembly language. It's easy to write poor code that is unclear. Even with the good code it can be hard to see what's going on. Computer programming 101 is 'never use GOTO'. With PICs it's almost impossible to avoid them.

Don't get too disheartened. It sounds as if you already managed to make inroads, and if you're serious about learning to use them then a navigation light system would be an excellent project to start on. Not so huge that it's insurmountable; but there's scope to learn about interrupts, and hardware, and lots more.

K

A bit like a kite, but 500 times more expensive
03-28-2008 02:56 PM
 
 
DesertDuster
New Heliman
Location: Tucson, AZ USA

I am curious has to what PIC to use for a project. I only know of the 16F84A because that's what my programmer tut entails. It's still very popular but some say it's out dated.

The 16F84A is a bit outdated but it's a good beginners choice. The step up to a 16F628A is a fairly easy one, and it's more capable and cheaper. The 16F628A has the same number of pins and the same I/O pin configuration as the 16F84A.

For a smaller option, I use the 12F675. This chip comes in a 8 pin through hole DIP package or small surface mount package.

I find it's pretty simple to modify code to work with either of these chips. This way if I don't need all those I/O pins available on the larger chip I can use the smaller one.

Are you going to be at the field this weekend? If so, I'll bring you one of each of these devices so you can try them. The 16F628A should work with whatever hardware you are using to program the 16F84A.

Bill
03-29-2008 02:18 AM
 
 
Girard Ibanez
Senior Heliman
Location: Tucson, Arizona (formally from Guam)

Not sure.

Haven't had an appetite to fly.



If it doesn't Hover, it Sucks or Blows.

MyRaptor.net Guam USA
03-29-2008 02:21 AM
HOMEPAGE  
 
 
Rappy 60
Senior Heliman
Location: Houston, Texas

The 12F675 is essentially the same as the 12F629. The 675 has an on board A/D Converter while the 629 does not. Both are the same size (8pin). Plenty of I/O, Interrupts, 16 bit timer/Counter, 8 bit counter, comparator...

Dale

Load "*",8,1
03-29-2008 04:43 AM
HOMEPAGE  
 
 
1 page352 viewsPOST REPLY
Mikado Modellhubschrauber . GrandRC . CanoMod

.
.
CAD - Engineering - Technical > PIC Navigational Lights; Assemby Code wanted / Circuit Design
  UPDATE SCREEN   PRINT TOPIC Advertisers 

Subscribe to This Topic

Tuesday, May 13 - 2:50 pm - Copyright © 2000 - 2008 runryder.com | email | link to rr | runryder needs cookie