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.

simple ADC program for PIC16F88 somehow gone wrong!

Status
Not open for further replies.

Steve311

Member
Hello All; I am trying to make a very simple ADC program with a PIC16F88 which reads only one input at AN4. The PIC has a 10bit output which I want to be shown on pins RB0-RB7, RA0 and RA1 by just sending a logic 1 or 0 to each pin. I am using MPLAB IDE and MPLAB SIM as the compilier. I notice there is an error which says ADC-W0008: No stimulus file attached to ADRESL for A/D. which I don't understand. I know the code is very close to what it needs to be but I am missing something subtle....Any suggestions or comments would be GREATLY appreciated here! Thanks in Advance....

And also, what would be the best way to test this? Im currently using a pot to vary a dc voltage at the input AN4 with a range between vdd and vss....will this suffice?

Attached is my .asm file
 

Attachments

  • A_D Conversion Code.asm
    4.2 KB · Views: 310
Check my tutorials, which take you through how to use the analogue inputs.

A simple pot is fine for a test, but it really needs to be a fairly low value, 5K or lower.
 
Last edited:
hi Steve,
Your program runs OK in the Oshonsoft simulator.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    16.1 KB · Views: 324
Thanks Eric; That makes me fuul much better....

I changed the code so the output is only a 8bit resolution, and I would like to send these values to RB0-RB7 respectively and have them be held high or low so I can read the output with a voltmeter at the pins....Do you see any issue with how I am sending these values to PORTB so i can read them? Thanks again!

Steve
 
Thanks Eric; That makes me fuul much better....

I changed the code so the output is only a 8bit resolution, and I would like to send these values to RB0-RB7 respectively and have them be held high or low so I can read the output with a voltmeter at the pins....Do you see any issue with how I am sending these values to PORTB so i can read them? Thanks again!

Steve

hi Steve,
If you post your latest code I will give it a run in the Sim.
 
Hi Eric; Thanks again i really appreciate it. Attached is my latest version. And again, my goal is to read the outputs on PORTB respectively.

Steve
 

Attachments

  • A_DConversionCode_asm.zip
    2 KB · Views: 211
Hi Eric; Thanks again i really appreciate it. Attached is my latest version. And again, my goal is to read the outputs on PORTB respectively.

Steve

Downloaded it, ok

EDIT:
Required editing, this now works.
Remember for 8 bit operation, its left justified and in ADRESH
 

Attachments

  • A_D Conversion Code.asm
    3.9 KB · Views: 291
  • AAesp02.gif
    AAesp02.gif
    44.6 KB · Views: 313
Last edited:
Hi Eric; Thank you very much for editing my code. I see everything working as planned now. I understand the changes you made and I see where I was going wrong. Knowledge is power!

Thanks Again!
 
Hi Eric, i am using the same PIC16f88 using RA0 as my input and RB0 as my output, then pin 5 and pin 14 for my power supply (+5v and -5v), then i am going to transmit it wirelessly, i have the code for the transmitter but i am really stuck on the A to D conversion.. please help.. many thanks!
 
...which says ADC-W0008: No stimulus file attached to ADRESL

When you are testing your program in MPLAB SIM, you can choose to simulate voltages on the A/D inputs to test your program properly.

These are called stimulus files. If you get that error that means there is no stimulus file. It's not a program error as such, but it's just letting you know that your A/D input will stay at 0v in the simulator and therefore can't be simulated properly.

I hope that made sense.
 
...pin 5 and pin 14 for my power supply (+5v and -5v)

PIC's aren't designed to accept a 10v input... If you do it the way you described, you will probably blow your PIC.

You really should start your own thread, though.
 
And i am measuring 0-5 voltage for my input then transmit it wirelessly, i only need an ADC code for my pic.. :( im really stuck..
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top