noobe needing big time help

Have you got the greatest 48 bit multiplier ever conceived? Prove it - post your code here.

Moderator: phalanx

Post Reply
Allenf
Posts: 3
Joined: Sun Jul 03, 2011 10:20 am

noobe needing big time help

Post by Allenf » Sun Jul 03, 2011 10:37 am

Ok I have been playing round with the pic for about a year and still cant get my head round it.
What I want to do is run from an external switch
two led`s on permenantly
loop one led to flash at a constant rate {strobe effect} (preferably that i can vary with a pot)
loop one led to start at a brightness of say 10% then ramp up to 90% flash at 100% then return to the 90% and ramp down to 10% at a rate variable with a pot
and repeat it until switch is thrown to off.

After a year of playing with the 16f627 all i can get is the two constant led`s to light.
Although there are many so called examples on the net they seem to be full of errors that I just don`t have the understanding to sort out and they just wont physically work. having tried to contact the numerous posters of these "snippets" to no avail I am at a total loss as to how to go about it
I understand that I will need to pulse the LED using a pwm but I`m afraid the language is just beyond my grasp without having it in front of me with all the ;rems in place so I can follow what it is trying to do

Please can someone help me out with the full asm coding for this project

Many thanks

Allen

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: noobe needing big time help

Post by waltr » Mon Jul 04, 2011 3:40 pm

I can point you to a good tutorial which does flash an LED (the basis for what you want to do). Do follow the tutorial from the beginning and do every lesson using MPLAB and its built-in Simulator. There is not a need to buy any parts of programming tools since you can learn about what the code does by stepping instruction by instruction in the Simulator. This you get you to understand what a PIC does and how to write real code.
Once you understand a lesson then write code for your 16F627 to do the same thing as the lesson.
Also, do read the various topics in the MPLAB Help, they do have good info.

Here's the tutorial:
http://www.gooligum.com.au/tut_baseline_C.html

Allenf
Posts: 3
Joined: Sun Jul 03, 2011 10:20 am

Re: noobe needing big time help

Post by Allenf » Tue Jul 05, 2011 2:02 pm

i can sort of get the led to flash ok using the BSF and BCF commands and call the delay in the midde.
What I cant do is FADE the led smoothly in and out it seems jerky (flashes each pulse).
I dont understand lots of pages of techiy data giving one command and one line stuff because I just cant put it all together so maybe Im on a loser before i start or not
surly a routine to call a pwm throw the duty cycle at an led and run quietly in the background cant be that hard, well to me its about as reachable as the moon.
All the reference i can find on the net talk about 18f series or oblsolete (pics trhat I personally can`t get). I want to use a 16f 627/8or a 12f

waltr
Support Volunteer
Posts: 2823
Joined: Tue Sep 08, 2009 12:07 pm
Location: Philadelphia, USA

Re: noobe needing big time help

Post by waltr » Tue Jul 05, 2011 5:02 pm

It not you. There are many code examples out there that I'll scratch my head over how they work. So keep reading but more important keep writing code.

One of the things I really like about PICs is the compatibility between the different devices and even between some of the different families. If you find code for a 16F84 (fairly old PIC) there is very little to change to get the code to run on a 16f627. In fact the pin outs are the same so you could insert a 16f627 into a board designed for the 16F84 (or for the really old 16C72).

A hint on writing code: Write out what you want the code to do in the language you speak (English for me) step by step. Then start working on what code will do what you wrote out. Use what you wrote out for the comments then as you debug you can check to see if the code does what you wrote.

Instead of just trying to understand someones code, work on how to get a processor (code) to do something. Your fading an LED is an example. Start by setting up a hardware timer (TMR0 for example) to time out a period that the LED will be cycled on/off. This period should be constant. Then if the LED is on for the whole period that is a 100% duty cycle. If its on for half the time then its a 50% duty cycle.
Then vary the percent of the period that the LED is on to vary its brightness.

Do each lesson of the Tutorial I gave you. By the time you finish you will be able to write the code to fade an LED on/off.
Writing code is not easy when you start so do stick with it and it will become easier.

Post Reply