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.

Mplab sim a/d question

Status
Not open for further replies.
I would like to know how to set up an input in mplab sim to trigger an a/d pin an0 to trigger my program. I get this but I don't know what to do with it.

Stimulus: Synchronous stimulus applied successfully.
ADC-W0008: No stimulus file attached to ADRESL for A/D.

I've tried to set up the input, but I really have no idea what I need to do to modify if to get it to work. If you could give me a description or a sample input that I could use to base mine off of that would help alot. Thanks!
 
Informative thread! Learnt a lot!
 
It's always nice when someone asks a question, figures it out, and never says how they did it. Then later on, when someone searches to try and find the answer to the same question, they find that thread and are disappointed to find no answer. It becomes yet another useless thread that just clutters up search results, and discourages people from searching for existing answers instead of asking the same old questions over and over.

Anyway, just in case the original poster doesn't come back and do it themselves, the answer (to the question as I understood it) pretty much lies in the warning message about "no stimulus file attached"... the ADC module picks values from a stimulus file during simulation - it's something you can make easily in a text editor, and there is enough information in the MPLAB help files to get you going.
 
Sorry, no fix yet, just some head scratchin'. Still haven't figured out how to put the right value to my input. once the a/d conversion is finished it just reads like there was nothing 0 on the input.
 
Have you seen this in the simulator help
Stimulus Dialog
Use the Stimulus dialog to create synchronous or asynchronous stimuli. The Stimulus dialog allows you to enter stimulus information which is saved in a file called a workbook. To open a new workbook, select Debugger>Stimulus>New Workbook. To open an existing workbook for editing, select Debugger>Stimulus>Open Workbook.

The following

I've tried to set up the input, but I really have no idea what I need to do to modify if to get it to work. If you could give me a description or a sample input that I could use to base mine off of that would help alot.

is the same as saying gosh it dont work.
 
I've got stimulus on an0, ra0, adresh, adresl, but I must not be doing something right, its still not working. I've been reading the help and it helps a little but I'm still fuzzy on my particular problem. I'll try changing the values some more and see if that helps tonight, even though I'm not getting any results any way. I may take a sixxer to fix it.
 
just setting up stimulus in the "pin/register actions" section, or are you doing an actual stimulus file via "register injection"?
since you mention ADRESH and ADRESL separately I'm guessing you're using regular stimulus rather than register injection.
In the register injection method, you feed in 12-bit values (as 16-bit hex numbers) from a stimulus file, to the ADRESL register. It's smart enough to break the value in two and put it in both ADRESH and ADRESL appropriately.

A picture is worth a thousand words, so one is attached. This is from MPLAB 7.50, things may be different in old versions as I remember they changed the stimulus stuff quite a bit a few releases ago.

The contents of 'adcstimulus.txt' is just hex values, one per line:
0x0101
0x0123
0x0321
(etc...)
Every time the program performs a read on the ADC, it will just grab the next value from this file.
 

Attachments

  • untitled.PNG
    untitled.PNG
    15.2 KB · Views: 1,906
Sweet, man! Thanks for the screenshot it was just what I needed! I built a text file with all the analog values and slid it into the "data filename" slot and it worked great! I've had this project on the shelf for a while, but this is just what I needed to get it going again! Many thanks!
 
Thanks EvanDude,
I didn't know you could do that. I can see that coming in very useful in future.

Mike.
 
I am getting this error when doing A/D conversion

ADC-W0010: A Minimum of 2 TADs are required before another conversion should be started.
MAXIMUM number of warnings/errors exceeded 200, program execution halted.

Can anyone please sort me out whats the problem in this program

#include<P16f877A.inc>
ORG 0X00
REG1 EQU 0X29

BCF STATUS,RP1
BCF STATUS,RP0
MOVLW 0X81
MOVWF ADCON0 ; fosc/32...channel 0....power up a/d converter

MOVLW 0XFA ;delay
MOVWF REG1
NOP
DECFSZ REG1,1
GOTO $-1

MOVLW 0X00
BSF STATUS,RP0
MOVWF ADCON1 ; left justified
MOVLW 0XFF
MOVWF TRISA ;port a i/p
MOVWF TRISE ; port e i/p
MOVLW 0X00
MOVWF TRISC ;port c and port d o/p
MOVWF TRISD

MOVLW 0XFA
MOVWF REG1 ; load 250 in reg1
NOP

DECFSZ REG1,1 ; wait
GOTO $-1
MOVWF REG1
NOP
DECFSZ REG1,1
GOTO $-1
MOVWF REG1
NOP
DECFSZ REG1,1
GOTO $-1

BCF STATUS,RP0
BSF ADCON0,2 ; start conversion
GOTO $-1

MOVF ADRESH,0
MOVWF PORTC
BSF STATUS,RP0
MOVF ADRESL,0
BCF STATUS,RP0
MOVWF PORTD
END

stimulus applied 0x0102 ;;;
0x0202
0x0302
0x3202
0x4902
0x2872
0x0120
ox0123

WATCH: AFTER THE EXECUTION

ADRESH 0x40
ADRESL 0X80
TRISA 0X3F
ADCON0 0X85
ADCON1 0X00

I am not able to understand what these stimulus values means( i jus wrote them seeing the values in this thread)....

CAN SOMEBODY PLS TELL ME WHATS THE PROBLEM IN THIS PROGRAM...AND WHATS THE RIGHT ANSWER.....I NEED IT URGENTLY...

THANK U.....
 
You have missed a line,
Code:
		bcf	STATUS,RP0
		bsf	ADCON0,2	; start conversion
		[COLOR="Red"]btfsc	ADCON0,2[/COLOR]
		goto	$-1

		movf	ADRESH,0 
		movwf	PORTC
		bsf	STATUS,RP0
		movf	ADRESL,0
		bcf	STATUS,RP0
		movwf	PORTD

hang		goto	hang

You should also add the last line so the code stops.

Mike.
 
Thank you pommie... i am not gettin ny error nw!

for this stimulus
0x0123
0x0124
0x3022
0x3233
0x4942
0x2842
0x0150
ox0523

i am getting the output as
ADRESH 0x48
ADRESL 0xC0
TRISA 0x3F

can somebody explain me what this stimulus is all about??

and how the conversion in done(to check whether i am getting the correct o/p r nt?)
 
That is correct, you have the ADC set to left justify and so the 0x123 get shifted left 6 times to become 0x48c0.

Mike.
 
Sorry but I am new to using PIC. I have tried to program this onto my pic microcontroller so that i can display stuff on the LCD of my PIC millenium board. But for some reason I cant program it. Is it because I need to include a driver for LCD? The port used should be D. Can somebody sort this problem out. Thanks

#if defined(__PCB__)
#include <16C56.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)

#elif defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#endif

#include <lcd.c>
#include <kbd.c>


void main() {
char k;

lcd_init();
kbd_init();

lcd_putc("\fReady...\n");

while (TRUE) {
k=kbd_getc();
if(k!=0)
if(k=='*')
lcd_putc('\f');
else
lcd_putc(k);
}
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top