Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

goto $-1.............clrf LoX............ ?

Status
Not open for further replies.

timothyjackson

New Member
Hello all.

Silly little queries. Trying to understand how to make IR modulated signal transmission and reciever. Using Nigel Goodwins Tutorial 5.

In Read_pulse section/routine, its starts with "clrf LoX", clearing file register (i.e. make 0) LoX,,,,
what is so special about this file register?
Does it make the entire register 00000000?

The third line with the routine is "goto $-1" I can't find this labelled routine anywhere. Is this a special trick in PIC programming. ?
 
timothyjackson said:
Hello all.

Silly little queries. Trying to understand how to make IR modulated signal transmission and reciever. Using Nigel Goodwins Tutorial 5.

In Read_pulse section/routine, its starts with "clrf LoX", clearing file register (i.e. make 0) LoX,,,,
what is so special about this file register?
Does it make the entire register 00000000?

LoX is a varable name I assigned for a GPR, this simply zero's it.

The third line with the routine is "goto $-1" I can't find this labelled routine anywhere. Is this a special trick in PIC programming. ?

It's explained in the MPASM helpfile, but basically '$' is the current address, so 'goto $-1' means jump back one line. Likewise, 'goto $+1' means jump forward one line - which you might think is pointless, but a 'goto' takes two instruction cycles, so it takes twice as long as a 'NOP'. So it's useful in delay routines, as a 'super NOP' :lol:
 
timothyjackson said:
The third line with the routine is "goto $-1" I can't find this labelled routine anywhere. Is this a special trick in PIC programming. ?

$ means the address you're at. $-1 means one address up. You can use it when you check a bit. Example.

start
BTFSS PORTA,1
GOTO start

instead you can write:
BTFSS PORTA,1
GOTO $-1
 
thankyou both.

I understand these now.

With the Prockeys routine (same tutorial), flags2, new is tested, if set the device code id matched....then button matching continues to activate the correct LED output. My question is: in the IRread sub routine, I cannot find anywhere which sets the flags2, new bit. OR, is this flags2, new, bit automatically set when any bit in the flags gpr is set?

furthermore... its seems the LED is toggled on and off first...Have I made a mistake in thinking this. If I wanted to just activate the appropriate LED, I could just skip this and move to the the correct Key "?" (i.e. 1 to 3) routine? (I want my LEDS to be normally off, and illuminated for 5 seconds according to the code recieved...

apologies for complex questions...

:?
 
timothyjackson said:
thankyou both.

I understand these now.

With the Prockeys routine (same tutorial), flags2, new is tested, if set the device code id matched....then button matching continues to activate the correct LED output. My question is: in the IRread sub routine, I cannot find anywhere which sets the flags2, new bit. OR, is this flags2, new, bit automatically set when any bit in the flags gpr is set?

It's set by BSF in the 'Still_High' routine and cleared by BCF in the individual Key routines, try doing a text search, you'll see where it's done.

furthermore... its seems the LED is toggled on and off first...Have I made a mistake in thinking this. If I wanted to just activate the appropriate LED, I could just skip this and move to the the correct Key "?" (i.e. 1 to 3) routine? (I want my LEDS to be normally off, and illuminated for 5 seconds according to the code recieved...

Yes, it's designed to toggle the output ON and OFF (that's the function of 'Flags2, New'). you would need to alter the Key routines to do what you want.
 
Please Check this

Attention to all PIC experts (nigel).

I have modified some code (nigels tutorial 5) code. The application is basically 2 boxes, which communicate with IR, en/decoded using PIC. One box has 8 transmission buttons which each send different message. The reciever (other) box reads the code, and turns on a relevant LED for 5 seconds.

Attached are the 2 modified program codes: one for reciever; 1 for transmitter, and also a flow chart at the bottom (all .doc)

Im a few weeks into the world of PIC's, and I am scared about having made some errors. I guess, all these questions are geared to finding out if this will work? Please refer to the attached documants.

The Reciever (originally tutorial 5.3)

1.) __config 0x3D18 Does this set up the oscillator, and, setup the option_reg?

I don’t see how this set’s up the TMR0 or prescaling. Or is this a lookup file?

2.) I Have removed the EE_write routine; Both the “call” and the “routine” has been removed. EE_read has also been removed, as, the output ports are intended to be in logic 0 in normal & startup state. The “call” and the “routine” has been removed.

I removed these as the output ports were being “bsf” for 5 seconds [timeloop], and then “bcf”.

If am wrong, can you briefly explain why?

3.) Is this routine correct “LED_5sec”?

The Transmitter (originally tutorial 5.2)

1.) SW1 Equ 7 ;set constants for the switches

Are these commands assigning “switches” to relevant bits of porta?

2.)ProgUp Equ d'16'

This scares me a little. I deleted the 4 device prompts (vol up/down, prog up/down); switches now “movlw” from the But”x”, and this is transmitted. I think? Im not too sure about this.

I made these changes because I don’t need to achieve specific functions like volume up, etc. I just need each one of the eight buttons to turn on a relvant LED (using the BUT”x” id?).

Is this correct?

3.) Have I made any mistakes/oversights now that 8 switches are being used?

Looking forward to feedback


Many thanks to you all. Big thanks to Nigel.

:)
 

Attachments

  • master_file_-_n.goodwin_modification.doc
    44 KB · Views: 493
Re: Please Check this

timothyjackson said:
Attention to all PIC experts (nigel).

I have modified some code (nigels tutorial 5) code. The application is basically 2 boxes, which communicate with IR, en/decoded using PIC. One box has 8 transmission buttons which each send different message. The reciever (other) box reads the code, and turns on a relevant LED for 5 seconds.

Attached are the 2 modified program codes: one for reciever; 1 for transmitter, and also a flow chart at the bottom (all .doc)

Im a few weeks into the world of PIC's, and I am scared about having made some errors. I guess, all these questions are geared to finding out if this will work? Please refer to the attached documants.

The Reciever (originally tutorial 5.3)

1.) __config 0x3D18 Does this set up the oscillator, and, setup the option_reg?

No, it sets the config fuses for the chip.

I don’t see how this set’s up the TMR0 or prescaling. Or is this a lookup file?

Because it doesn't, they are not used.

2.) I Have removed the EE_write routine; Both the “call” and the “routine” has been removed. EE_read has also been removed, as, the output ports are intended to be in logic 0 in normal & startup state. The “call” and the “routine” has been removed.

I removed these as the output ports were being “bsf” for 5 seconds [timeloop], and then “bcf”.

If am wrong, can you briefly explain why?

Looks fine.

3.) Is this routine correct “LED_5sec”?

The Transmitter (originally tutorial 5.2)

1.) SW1 Equ 7 ;set constants for the switches

Are these commands assigning “switches” to relevant bits of porta?

Yes.

2.)ProgUp Equ d'16'

This scares me a little. I deleted the 4 device prompts (vol up/down, prog up/down); switches now “movlw” from the But”x”, and this is transmitted. I think? Im not too sure about this.

I made these changes because I don’t need to achieve specific functions like volume up, etc. I just need each one of the eight buttons to turn on a relvant LED (using the BUT”x” id?).

Is this correct?

3.) Have I made any mistakes/oversights now that 8 switches are being used?

On a quick look it seems fine!.
 
Nigel. you have no idea how much I trust/appreciate your replies.

I guess, the next thing is to simulate this in MPLAB?

If thats OK, buy a development board, and burn a chip, and see if it works?

I'm going to get development boards from mikroelectronica;

? or should i do this another way?

:D
 
timothyjackson said:
Nigel. you have no idea how much I trust/appreciate your replies.

I guess, the next thing is to simulate this in MPLAB?

If thats OK, buy a development board, and burn a chip, and see if it works?

I'm going to get development boards from mikroelectronica;

? or should i do this another way?

:D

If you've got veroboard, you can simply build my tutorial boards, they are more versatile than development boards as you can add new ones easily. Also cheaper than buying boards :)

Personally I never use MPLAB, I just use the MPASM assembler.
 
Nigel Goodwin said:
If you've got veroboard, you can simply build my tutorial boards, they are more versatile than development boards as you can add new ones easily. Also cheaper than buying boards :)

Personally I never use MPLAB, I just use the MPASM assembler.

I can't download your tutorials. My pc comes up with an error missing .dll file. I emailed you to the address on your tutorials site a few days ago. Would love to see your tutorials. Is it possible to email them in another format?

MPASM, where can I donwload that from?

I ready to get on to a tutorial board.

:twisted:
 
timothyjackson said:
Nigel Goodwin said:
If you've got veroboard, you can simply build my tutorial boards, they are more versatile than development boards as you can add new ones easily. Also cheaper than buying boards :)

Personally I never use MPLAB, I just use the MPASM assembler.

I can't download your tutorials. My pc comes up with an error missing .dll file. I emailed you to the address on your tutorials site a few days ago. Would love to see your tutorials. Is it possible to email them in another format?

It's just a selection of web pages, no DLL's required. I presume what you've downloaded is WinPicProg? (my programmer software), you need to download the port driver as well (it's on the same page).

MPASM, where can I donwload that from?

From MicroChip, it's installed as part of MPLAB, you can't download a recent seperate version.
 
Both your modified code programmes were loaded into my MPLAB (never used it before). Both programmes built successfully. I have a few queries:

1.) _config 0x3D18

What is this? Within MPLAB it has a ";" preceeding this, therefore it acts as note?

2.) In the Receiver code, one error was to do with the cblock command: "warning [205].....Found directive in colomn 1"
I deleted a few of the GPR´s not required i.e. "lastdev", "lastkey" - seems to have removed this error`(doesn´t come up on "buildall" instruction anymore)

3.) "error section`org-1´ cannot fit the absolute section. ??I changed "org 0x0004 to org 0x0005, as per the transmitter code, and these seems to have stopped the problem.

OK my girlfriend has just turned up, and demanding we go.

More queries as and when. But so far, they both build sucessfully, and, you´re a genious.

more posts tomorrow.

TJ

:D :D :D
 
timothyjackson said:
Both your modified code programmes were loaded into my MPLAB (never used it before). Both programmes built successfully. I have a few queries:

1.) _config 0x3D18

What is this? Within MPLAB it has a ";" preceeding this, therefore it acts as note?

It's an assembler directive, it sets the configuration fuses for the chip, I never use MPLAB (I use MPASM) so I can't comment on what it might, or might not, do!.

2.) In the Receiver code, one error was to do with the cblock command: "warning [205].....Found directive in colomn 1"
I deleted a few of the GPR´s not required i.e. "lastdev", "lastkey" - seems to have removed this error`(doesn´t come up on "buildall" instruction anymore)

That's only a 'warning' not an error, and doesn't have any real effect.

3.) "error section`org-1´ cannot fit the absolute section. ??I changed "org 0x0004 to org 0x0005, as per the transmitter code, and these seems to have stopped the problem.

I don't know?, presumably it's something MPLAB doesn't like?. 0x004 is the interrupt vector, perhaps MPLAB won't allow normal code there?.
 
thanks nigel. Ploughed through my notes again today (getting ones head around things), and these still concern me:

1.) The Configuration bit. What have you specified here: (I just want to understand this on a basic level- I imagine, like with the status/interupt/option configuration method, you have specified this number to set up the fuses?

_config 0x3D18

2.) I don´t understand the "programmer" stage (i.e. PIC Start PLus, PIC Kit1 etc). Is this the language which the software (MPLAB) uses to burn the information into the chip?

3.) I want to get a development board from Mikroelectronica, do I need to be careful about which "programmer" they can be used with? Im a little lost here.

4.) In simulation of the code (Your modified IR circuits), the simulation will keep looping at a stage i.e. waiting for a signal to be received, how can I simulate a recieved signal, so that the rest of the code can be simulated? I understand that you don´t use MPLAB, and therefore don´t expect you to know.

5.) OK. So, the flow chart is done.......the code is done......the code is built succesfully......the code simulates succesfully........what next?

Is it. Assemble code > Programme code into chip > test chip.

6.) Is there a method of testing the circuit in a chip? rather than blowing a heap of chips before getting it right? Or, is there a re-programmable chip option (16F628)

OK. Enough for now. Asked you loads of stuff already. Just one last one.

Any good links for studying howe to do PWM, I want to learn how to fade LED´s on and off slowly using my new found PIC understanding?

:D :D :D :D :D :D :D :D :D :D :D :D
 
timothyjackson said:
thanks nigel. Ploughed through my notes again today (getting ones head around things), and these still concern me:

1.) The Configuration bit. What have you specified here: (I just want to understand this on a basic level- I imagine, like with the status/interupt/option configuration method, you have specified this number to set up the fuses?

_config 0x3D18

It's simply set to use the internal 4MHz oscillator, and all other options turned OFF.

2.) I don´t understand the "programmer" stage (i.e. PIC Start PLus, PIC Kit1 etc). Is this the language which the software (MPLAB) uses to burn the information into the chip?

No, the language you use is PIC assembler, this is converted (assembled) by MPASM/MPLAB to give a .HEX file. The .HEX is simply a way of storing the binary data for the PIC, the programmer simply takes this file and transfers the data from it into the PIC.

3.) I want to get a development board from Mikroelectronica, do I need to be careful about which "programmer" they can be used with? Im a little lost here.

As long as you can unplug the chip and place it in a programmer it doesn't matter what board you use, although the board itself might have provision for ICSP - which allows you to program it in the board.

4.) In simulation of the code (Your modified IR circuits), the simulation will keep looping at a stage i.e. waiting for a signal to be received, how can I simulate a recieved signal, so that the rest of the code can be simulated? I understand that you don´t use MPLAB, and therefore don´t expect you to know.

That's always the problem with simulators.

5.) OK. So, the flow chart is done.......the code is done......the code is built succesfully......the code simulates succesfully........what next?

Is it. Assemble code > Programme code into chip > test chip.

Yes.

6.) Is there a method of testing the circuit in a chip? rather than blowing a heap of chips before getting it right? Or, is there a re-programmable chip option (16F628)

For development you would use a FLASH/EEPROM chip (like the 16F628), or at the very least a JW (UV eraseable chip). For obvious reasons FLASH/EEPROM are by far preferable!.

OK. Enough for now. Asked you loads of stuff already. Just one last one.

Any good links for studying howe to do PWM, I want to learn how to fade LED´s on and off slowly using my new found PIC understanding?

One of my tutorials shows how to configure the PWM in a 16F876, you could start there.
 
Thanks Nigel.

To summarise.

1.) I now understand the config command (generally speaking)

2.) I understand that the code is "assembled", then the "programmer" option burns it into the PIC

3.) Simulators have a restriction. i.e. I cannot simulate received/transmitted data. I´m assuming the ONLY way round this is using the "stimulus" window, which, isn´t really explained in help.

4.) "For development you would use a FLASH/EEPROM chip (like the 16F628" This means I can constantly reprogramme to perfection. Once this code & circuit are perfected, is their a version of this chip which is not FLASH/EEPROM, which is cheaper, but has the same operational functions barr the flash/eeprom?

5.) I´m going to digest the Goodwinn PWM tutorial.

6.) Where is the best place to purchase PIC´s in the UK (i.e. low minimum order quantities etc.) Was giong to use DIgikey in the states - I heard service is top notch.

- Thanks Nigel. I appreciate this accelerated learning curve you facilitate.

until the next :twisted: :D
 
timothyjackson said:
4.) "For development you would use a FLASH/EEPROM chip (like the 16F628" This means I can constantly reprogramme to perfection. Once this code & circuit are perfected, is their a version of this chip which is not FLASH/EEPROM, which is cheaper, but has the same operational functions barr the flash/eeprom?

No, they don't do OTP versions of the FLASH/EEPROM chips, but they are quite cheap anyway. If you were making a commercial product you would probably initially develop using a FLASH chip, then port the code to a UV eraseable (JW) chip, then in production use an OTP chip.

Where this seriously falls down is if the code then needs changes after production, quite possibly due to a bug which never occured in testing.
I've seen this quite a lot in TV sets (in fact I've ordered two updated micros for Grundig TV's today), it costs a great deal more to replace every micro out there, and to throw away all the stocks of ready programed chips you have - than to use a reprogrammable chip in the first place.

Incidently, I mentioned Grundig (who went bust in 2003), they commonly fitted a socket for the micro in the first production runs, with a daughter board plugged into the socket that contained the micro and an EPROM. That way they could simply send out new EPROM's, and ask for the old ones back for reprogramming. If the first batches of production didn't have any faults the software would be burnt into OTP chips (or more probably manufactured ready programmed) for the later production runs.

6.) Where is the best place to purchase PIC´s in the UK (i.e. low minimum order quantities etc.) Was giong to use DIgikey in the states - I heard service is top notch.

For a start I would suggest ordering some from MicroChip as samples, you can order upto five chips - and it's free!.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top