Author Topic: Frustrated with programming  (Read 4797 times)

0 Members and 1 Guest are viewing this topic.

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Frustrated with programming
« on: April 11, 2010, 05:10:55 AM »
Hey.

Im a n00b at programming,and i can;t seem to achieve the most simple task.

I would like to program a PIC 16f84A .
Im using MPLAB v7.2 . And i downloaded  "HI-TECH C compile lite version".

Ok the theory says that i should first write the program,then compile it (so id get a .hex file) then upload it onto the PIC.I cant achieve the 1st two steps of that simple "theory".....


Does anyone have ANY(i mean ANY ) code that will just show me a "build successful" using the softwares i am ? (any code would do it...as dumb as it could be).

i tried a code i found somewhere :

#include <16F84A.h>
#use DELAY (CLOCK=4000000)

void main() {

   output_low(pin_C1);
   output_high(pin_C1);
}

and i get : can't open include file "16F84A.h": No such file............


May anyone please help me or just guide me ?

thanks a lot.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #1 on: April 11, 2010, 07:05:42 AM »
Check the gooligum tutorial:
http://www.gooligum.com.au/tutorials.html

This should get you started with both assembler and HiTech C.

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Frustrated with programming
« Reply #2 on: April 11, 2010, 10:40:40 AM »
That code you posted is written in C.  Google some tutorials on it.  It's actually quite a simple yet powerful language, once you get around all of the formatting.  That error that you got was because that file 16F84A.h is called a "header file"  It contains functions and things that the program needs to function normally.  I'm not sure exactly, but that person might have made their own header file, or included one that you don't have on your computer.  Hence the error. 

See according to the "theory" you write a program in a "high level" language.  I.E. one that uses english and is easy for people to write.  Then the "compiler" acts as a translator.  It takes the program and translates it to a language that the PIC 16f84A can understand (I.E. the hex file).  Then you simply give the PIC 16f84A the hex file so that it can read it and do whatever the program says.  Easy enough right?  Yes, writing the program itself is sometimes the hardest task, especially with microcontrollers, but once you get used to programming,  you should be good.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #3 on: April 11, 2010, 12:49:23 PM »
The gooligum tutorial covers this but to add to corrado33's post.

HiTech C does not require an include header file for a specific PIC. HiTech will use the MPLAB Selected Device under the Configure menu.

Try replacing the #include <16F84A.h> with the with this line:

#include <htc.h>

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #4 on: April 12, 2010, 11:01:12 AM »
wltr !!!

THANK YOU A LOT.......

Ive been searching for lots of tuts but in vain...........this one hit the target ...........i guess itll take me few months to read them all -_- but i love it : ).

Thanks a lot for your help.


(Got my first "BUILD SUCCEEDED" yaay...i know its stupid...but it feels good )

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #5 on: April 12, 2010, 12:09:43 PM »
Quote
(Got my first "BUILD SUCCEEDED" yaay...i know its stupid...but it feels good )

Congrats and I know that feeling when something finally works.

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #6 on: April 12, 2010, 02:18:12 PM »
One more problem please :

Im using a "Hand made programmer"..........

Its description is as follows :

"Professional quality PIC Programmer
. Quick and convenient with
USB port connection , it's ideal for use with
modern laptop computers. Reliable, high speed
programming and FREE Windows software
interface.
There is an Auto Program feature for fast no-keypress
bulk programming The board uses a modern
FT232BM IC for the USB and has on-board
firmware.
No need for any external power
supply, because the Hardware supply directly from
the USB port .
Software
Compatible with
9x/NT/2000/ME/XP
Software accepts HEX files and has Program,
Verify, Read, Blank Check, OSCAL and Fuse
functions."


THe software provided is PICmicro Programmer v141204 (with DIY K150,K170,K182,K149A etc.)
I can;t get to program it.......

Do you think i can use another "software"(programmer) but still use the same device im using ?

Thanks again.

Offline corrado33

  • Supreme Robot
  • *****
  • Posts: 611
  • Helpful? 11
Re: Frustrated with programming
« Reply #7 on: April 13, 2010, 11:31:12 AM »
Does the computer program give you any errors when it tries to program the pic?  It's more likely you have something wired wrong along the way, or your computer isn't recognizing the programmer correctly. 

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #8 on: April 13, 2010, 12:23:26 PM »
I am not familiar with that programmer but it may be a PICKit clone. I searched on Microchips site and found this thread in the forum. Maybe it'll help.
http://www.microchip.com/forums/tm.aspx?m=427949

Quote
I can;t get to program it.......

Does this mean the programmer is recognized by the computer?
Is the PIC detected?
What error are you getting.

I believe that programmer is for ICSP. Do you have any components connected the your PIC's ICSP pins? What do you have connected to the Vdd and Vpp pins? The programmer needs the bring up the voltage on Vdd & Vpp within a specific time for the PIC to go into programming mode. If there are caps on these pins the programming can fail.

Can you post a schematic of how the PIC is wired and the programmer connections.

Look at the ICSP guide found here:
http://search.microchip.com/searchapp/searchhome.aspx?q=ICSP&resperpage=10&id=2
for recommended connections.





Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #9 on: April 13, 2010, 02:25:40 PM »
Corrado , it gives me an error with "problem accessing the COM port" or "make sure that the programmer suits the board" (smth like tht) .

And waltr, i already checked that thread on microchip's forum but it didnt help.
and the PC does recognise it (when i first connected the programmer,a driver was "installed" automatically....) then when i go check the ports,it shows "USB serial convertor"..........

Ill take close pics of the programmer tomorrow and post them here if its possible.

Thanks

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #10 on: April 13, 2010, 03:55:54 PM »
That sounds more like a problem with the PC/OS/drivers or the programmer software or the programmer itself.
But it could still be the connections to the PIC's ICSP pins.

I think I have misunderstood your problem so let me rephrase what I think you said:

You are building a PIC programmer.
You are trying to load code (program) into the PIC used in the programmer.
This is not working.

If this is true do you have a link to information on this DIY programmer?

Here is a link to a forum on what I believe is the DIY programmer you have:
http://diykit.websitetoolbox.com/?forum=13943

I did see this:
Quote
The latest firmware/software is DIYpack25EP. You can download it from here.

Unzip to a folder on your PC. You will need another PIC programmer to re-program your 16F628A chip with the firmware for your programmer (epk149bf.hex). Once done you can then run the Microbrn software.


Could this be the trouble?

I did find:http://kitsrus.com/pic.html
Is this the kit you have?

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Frustrated with programming
« Reply #11 on: April 13, 2010, 06:25:16 PM »
Im using a "Hand made programmer"..........

Its description is as follows :
[Snip]
THe software provided is PICmicro Programmer v141204 (with DIY K150,K170,K182,K149A etc.)
I can;t get to program it.......

Do you think i can use another "software"(programmer) but still use the same device im using ?

It's definitely not a DIY (Kits 'R' Us) programmer, but it sounds like one of the numerous clones of one of the Kits 'R' Us programmers.

Go to Kits 'R' Us and work your way to their forum to see if you can get help. I have seen them help somebody with a clone, even if they have nothing to do with it and actually got their design stolen. Hats of to them!

Maintain utmost courtesy and politeness if you post on their board.
This is a Chinese business and while it counts everywhere when you need somebodys help, it does so double when it's a Chinese company - it's all about keeping a face, Even when the Triads blackmail a business manager, they are very polite and smiling (at least initially and as long as you play ball).


You might also just compare pictures of their programmers here or find them by their kit numbers anywhere on the net. That link will also lead you to some firmware updates, but whether it's wise to use them or not, I cannot say.

If you post some photos, shot from different angles (including readable letters/numbering it may hold), of your programmer, I'll see if I can help you further.

Btw. K149(A) as the text mentions is a very old revision of this programmer which is unfortunately not being developed anymore - I think the last revision is "D"
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline codeblue

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
Re: Frustrated with programming
« Reply #12 on: April 13, 2010, 07:37:03 PM »
... this is not really on topic, but the thing to remember when programmming is that your not gonna normally get a succesful buildyour first time, but to be pacient. When I started programming i thought it was impossible lol... but it just takes time.. Though i havent done any device programming yet

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #13 on: April 14, 2010, 01:42:40 PM »
http://www.ekt2.com/ekt/prodView.asp?idproduct=245353


This is the exact product......

(i tried posting the images i took with a more clear look,but the "insert image" button didnt work i guess.......)

And waltr , i am not building a programmer.i bought the programmer existing in the link above,from that company.(but it isnt a "microchip" production or wtv,thts y i told u tht its handmade).

Soeren thanks for the advice.i did compare the pictures but none of them is the one.

« Last Edit: April 14, 2010, 02:10:37 PM by wattson7 »

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #14 on: April 14, 2010, 02:19:23 PM »
Quote
i bought the programmer existing in the link above
Yep, I kind of thought that but wasn't sure.

Unfortunately I don't know how to help you with this programmer. Can you get tech support from where you bought it?

One option is to return it and get a refund of your money then buy a PICKit2 from Microchip. This is only $35 (plus shipping) and works very well under MPLAB as a programmer and debugger. It also has a stand alone utility to program and read PICs and also works as a 3 input logic analyzer or a UART interface.
I have been using a PICKit2 for a while and it does work.

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #15 on: April 15, 2010, 12:05:05 PM »
i would have loved to buy the microchip pickit 2 but unfortunately it doesnt exist here..(LEBANON..if uve heard of tht country)..............that shitty pic i bought is worth 35 $ !! ...............

anw ,ill try to dig it through..

Thankks a lot for all ur help..really...nice forum : )

Offline wattson7Topic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Frustrated with programming
« Reply #16 on: April 25, 2010, 10:27:24 AM »
Hey !

Ive finally got a "Programming complete"! .............All i had to do was to switch to windows xp and find a suitable driver.............

I have read the "Step-by-Step Robot Tutorial under $50" , but to my luck , it's done using an AVR chip(which i can't seem to find anywhere in the market here).....................So the question is , may i use a PIC16f84A ?(Or would i need an A/D option?) ....................and does anyone have a schematic for such a photovore with its assembly code so i could learn them or is it better that i try making them myself ?............

Thanks a lot.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 98
Re: Frustrated with programming
« Reply #17 on: April 25, 2010, 10:44:26 AM »
There are methods to read a analog voltage with a digital input using a resistor and a cap. This is called the RC timing method and is discussed in Microchips Tips'nTricks, TIP#13:
http://ww1.microchip.com/downloads/en/devicedoc/40040b.pdf
Along with APP notes AN512 for more details and example source code.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en010996


I have used this method on 16F84 PICs and it works well. This should be fine for reading an LDR for a photovore.

Great that you have the programmer working. You are making progress.



 


Get Your Ad Here

data_list