Simluting ADC on development Board

For users of Matrix Multimedia Electronics software to discuss projects, circuits and any other electronics concepts.

Moderators: Benj, Mods

Post Reply
lee_smith_ljmu
Posts: 10
Joined: Mon Feb 23, 2009 4:34 pm
Contact:

Simluting ADC on development Board

Post by lee_smith_ljmu »

my code is to display a varying 0-5v Dc voltage. when 5V Dc is applied at AD0 the bottom line of LCD is to display all blocks, when voltage is decreased the amount of blocks shown on the LCD decreases in line with the voltage (a sort of bar graph using a LCD)

my code works fine when simulated (using the thermometer as a way of varying the voltage at ADC0) and compiles to the PIC16F876 fine.

My problem is that i don't know how to set the development board so i can use external inputs to supply the voltage to the ADC0.

regards

Lee

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Simluting ADC on development Board

Post by Benj »

Hello Lee

You can feed in external signals into analogue channel 0 by using the screw terminal marked RA0. The signal will not be 100% clean as the LED and Switch circuitry on the board use pull down resistors but you should be able to get a fairly clear signal into the chip.

If you wish to use a potentiometer then you can use the one onboard the Dev board connected to ADC channel AN1. Then move the jumper at J14 position 1 to the ANA mode. Potentiometer RV3 will then be connected directly to AN1 in a clean manner. AN0 is connected to the Light dependant resistor via jumper J14 when in ANA mode so is probably not as useful for your application.

lee_smith_ljmu
Posts: 10
Joined: Mon Feb 23, 2009 4:34 pm
Contact:

Re: Simluting ADC on development Board

Post by lee_smith_ljmu »

accarding to the PIC Microcontroller development board data sheet, to use the external I/O ports for portA all jumpers must be removed, which i have done.

The Dc voltage applied to the ports is supplied from a power supply unit where the 0V is connected to OV on the board and +V connected to A0 to connect to ADC0of the PIC16F876.

i am still not getting any response, are my conections correct?

Regards
Lee

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Simluting ADC on development Board

Post by Benj »

Hello Lee

You do not need to use an external supply if you do not wish to. If you just need a potentiometer then I suggest using the suggestions above... pardon the pun. If you require the external supply then it can go between 0V and 5V. If your external supply is greater then this then you will have to use a potential divider circuit to allow the voltage to be in the correct range. The grounds should be tied together and then the external voltage can be fed into screw terminal RA0. You can attach your program to the forum if you like and I will see if there is something simple stopping the analogue from working. Also you are correct removing the analogue / digital jumper will allow for a clean signal to be received from the screw terminals.

lee_smith_ljmu
Posts: 10
Joined: Mon Feb 23, 2009 4:34 pm
Contact:

Re: Simluting ADC on development Board

Post by lee_smith_ljmu »

Hello Ben

sorry about the delay since last post .I have tried what you said in the previous post. for connection to the screew terminals i have removed all the jumpers and connected A3 to 5V and A2 to 0v for my Vref range then i have connected my variable voltage (0v-5v) to A0. still the LCD is not displaying the result. i have attached my flow code, which works fine in simulation and diplays the writing fine but not the ADC result. please could you have alook to see if there is anything simple stoping from working.

Regards

Lee
Attachments
tested version_final.fcf
(55.06 KiB) Downloaded 412 times
tested version_final.c
(46.24 KiB) Downloaded 388 times
tested version_final.asm
(39.15 KiB) Downloaded 382 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Simluting ADC on development Board

Post by Benj »

Hello Lee

Each AN pin is an analogue pin in its own right. You should anly need one I/O pin of the microcontroller to perform the analogue functionality.

Eg
Potentiometer pin 1 - +V (5V)
Potentiometer pin 2 - Microcontroller analogue pin eg RA0
Potentiometer pin 3 - GND

Vref is set to VDD (5V) and VSS (GND) as standard unless you have altered the code in the chip definition (FCD) file so you do not need to worry about these inputs.

Jumper J14 position 0 should be in the digital position to override the analogue light sensor connected to this channel.

Alternativly you could change your ADC component connections to AN2 in Flowcode and then move jumper J14 position 2 to ANA mode. This will disconnect the digital switch and LED circuitry allowing for a cleaner input signal. If you are doing this then pin 2 of the Pot should be connected to screw terminal RA2.

Hope this helps.

lee_smith_ljmu
Posts: 10
Joined: Mon Feb 23, 2009 4:34 pm
Contact:

Re: Simluting ADC on development Board

Post by lee_smith_ljmu »

Hello Benj,

Sorry but i am not flowing that last post. I need to supply a varying external voltage at ANO (Pin 2, on PIC) ranging from 5v to gnd. i have tried removing all jumpers put this did not work. as PINs 2 and 3 set the voltage reference for the ADC, do i need to connect these pins to +5v and 0v via the screw terminals.

Regards

Lee

lee_smith_ljmu
Posts: 10
Joined: Mon Feb 23, 2009 4:34 pm
Contact:

Re: Simluting ADC on development Board

Post by lee_smith_ljmu »

Hello ben,

i have tried the Potentiometer settings, i.e move jumper A0 to analgue butstill there is no result on the display only top line text. if the sumaltion works fine. is there something that maybe stopping this from working in the program?

regards
Lee Smith

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Simluting ADC on development Board

Post by Benj »

Hello Lee

Your problem is this.
as PINs 2 and 3 set the voltage reference for the ADC
Pins 2 and 3 do not set the voltage for the ADC. These pins are optional voltage reference pins but they are standard I/O by default. Even in reference mode (which is only enabled by editing the target FCD file) these pins are inputs for the reference voltages, they do not supply the reference voltages.

You need to connect your Potentiometer between 5V (+V) and GND with the middle pin going to RA0.

Post Reply