PIC16F84

fax

New Member
I am currently doing a voiced controlled robot (as instructed by the book "PIC Robotics" by John Iovine) that requires the use of a PIC16F84 microcontroller to decode the output of the speech recognition chip HM2007.

I got the following programming code from that book.

---------------------------------------------
'Speech recognition interface program
symbol porta = 5
symbol trisa = 133
symbol portb = 6
symbol trisb = 134
poke trisa, 255
poke trisb, 240
start:
peek portb, b0
if bit4 = 0 then trigger 'Trigger enabled, read speech recognition circuit
goto start 'Repeat
trigger:
pause 500 'Wait .5 second
peek portb, b0 'Read bcd number
if bit5 = 1 then send 'Output number
goto start 'Repeat
send:
peek porta, b0 'Read port a
if bit4 = 1 then eleven 'Is the number 11
poke portb, b0 'Output number
goto start 'Repeat
eleven:
if bit0 = 0 then ten
poke portb, 11
goto start 'Repeat
ten:
poke portb, 10
goto start 'Repeat
end
---------------------------------------------

After I installed Programming Editor and trying to compile the code, I got several errors in the above programming code. What is wrong? Is the book wrong?

I am new to programming and microcontroller so please help! (with plain english of course as I am not very familiar with this kind of stuff^_^)
 

hippy

Ex-Staff (retired)
The code is written for a PIC16F84 using a dialect of the Basic programming language which is not the same as that used by the PICAXE. 'PORTA' and 'PORTB' are both reserved words. Change them to "XPORTA" and "XPORTB" through the entire code and the program will compile.

Unfortunately, even when you've done that, the program will still not work on the PICAXE-18 range because the PICAXE is not a 16F84 and the hardware as indicated by the above program is incompatible with the PICAXE.

You would have to re-design the hardware and rewrite the program to use a PICAXE chip.
 

fax

New Member
But if I use a PIC16F84A chip with the above code, will I be able to program the IC directly using Programming Editor?
 

demonicpicaxeguy

Senior Member
ok the pic16f84a you have is a raw pic it's also a chip that i think has been discontinued or superceeded by microchip

the programming editor is stictly for use with the picaxe

the picaxe is a preprogramed pic chip but with an interpreter on it that allows it to run our programs written in the editor
 

manuka

Senior Member
First see perhaps =&gt; <A href='http://www.picaxe.orcon.net.nz/pcxtype8.jpg ' Target=_Blank>External Web Link</a> The entire Picaxe family (of now 11!) are based on MicroChip PICs that Rev.Ed &quot;enhances&quot; in their UK factory. To run code such as you've shown will need a Picaxe- probably an 18X.

When was this book written? It strikes me the raw PIC example has become scrambled by the author with Picaxe or Basic Stamp code -that 16F84 PIC (although once very popular) has been obsolete since ~2003!

EXTRA: If you are a Picaxe newbie then <b>start simply </b> with the ever popular 08M by following ideas at sites such as <A href='http://www.picaxe.orcon.net.nz ' Target=_Blank>External Web Link</a>



Edited by - manuka on 18/04/2007 12:59:24
 

Dippy

Moderator
A very quick sqiz at data sheets indicates that just with a few minor changes (example Hippy's suggestion) that you could use an 18X.
I haven't seen the schematic (or pondered over code for more than 10 seconds) so can't comment but it may almost be a simple chip swap (assuming no xtal issue).

But, as said, you can't just pick up any old PIC and use the PICAXE Programme Editor.

Edited by - dippy on 18/04/2007 14:43:22
 

fax

New Member
OK. I know why I got all those errors now. The original code is written for the PicBasic and I am using PicBasic Pro. Therefore I twisted the code to suit the pro version and it now compiles flawlessly.

Here is the twisted code for Pro version. The code inside the bracket is the original code.

------------------
'Speech Recognition Interface - PIC16F84A
'PicBasic Pro Version
'(symbol porta = 5)
'(symbol trisa = 133)
'(symbol portb = 6)
'(symbol trisb = 134)
trisa = 255 '(poke trisa, 255)
trisb = 240 '(poke trisb, 240)
p var byte 'for peek
q var byte 'for poke
start:
p = portb '(peek portb, b0)
if p.4 = 0 then trigger '(if bit4 = 0 then trigger)
goto start
trigger:
pause 500
p = portb '(peek portb, b0)
if p.5 = 1 then send '(if bit5 = 1 then send)
goto start
send:
p = porta '(peek porta, b0)
if p.4 = 1 then eleven '(if bit4 = 1 then eleven)
portb = q '(poke portb, b0)
goto start
eleven:
if p.0 = 0 then ten '(if bit0 = 0 then ten)
portb = 11 '(poke portb, 11)
goto start
ten:
portb = 10 '(poke portb, 10)
goto start
end
------------------

Now, how can I program the .hex code into the chip? Do I have to buy one of those programmers (cost hundreds) or can I connect the IC directly to the serial/parallel port just like nornmal PICAXE IC? If so, what's the connection diagram?

Edited by - fax on 18/04/2007 23:00:34
 

manuka

Senior Member
PicBASIC,although very akin to the Picaxe PBASIC,indeed apparently needs a $$$ programmer. <b>In contrast the PICAXE family program under Rev. Ed's totally free high level Win editor, via a serial port link &amp; just 2 resistors </b> . No wonder most &quot;PIC&quot; users (including of course the smiling faces on this esteemed forum) find the latter approach THE appealing way to go that!

Suggestion- forget about your present project for a while &amp; get to know Picaxes, as the 18X looks able to handle your needs.

Stan- now onto his 5th Picaxe year!
 

Technical

Technical Support
Staff member
You need one of those (as you said, can be expensive) programmers to try and work with that old (obsolete) chip in the way you are implying...

Or you could simply make life much easier/cheaper and use the PICAXE system instead (after all, this is a PICAXE forum....)

You would simply have to make sure the input/output layout matches an 18X layout and then make simple modifications to the program.
 

papaof2

Senior Member
If you have the software to write the hex file to a &quot;bare&quot; PIC (*not* a PICAXE), the least expensive PIC programmer is the JDM design. You can Google for instructions to build your own:
JDM programmer
(home URL is <A href='http://www.jdm.homepage.dk/newpic.htm' Target=_Blank>External Web Link</a> http://www.jdm.homepage.dk/newpic.htm )
or go to Ebay and search for:
serial pic programmer
or
JDM programmer
to purchase an assembled &amp; tested version for under $20US (delivered in the US). You should pay a few dollars more to get one with a ZIF socket, but be sure to compare price + shipping, not just price.

John
 
Top