MPLAB ICD 2 usage

I have downloaded MPLAB IDE v8.30 and installed it. I wanted to communicate PIC18F452 and PC I am using a sensor for my project which gives analog data.I am digitizing using 10 Bit ADC in the PIC. I want save the data from the ADC to a file in the computer. Now how should I proceed in the programming the PIC. Can you help me in this regard? I am trying to use ICD 2 module in the MPLAB software. Thank you.

Reply to
kiran_hk
Loading thread data ...

You may need to learn how to program either in assembly or c and read documentation with understanding. What skills and experience do you already have?

Jon

Reply to
Jon Kirwan

Do it with FlashForth. It will impress your teachers.

formatting link

Reply to
Mikael Nordman

How do you want to save the analog data ?? What is your hardware design ?? Are you in a programming class or a hardware class ??

First thing to learn: Write the specifications for your project.

Your future boss will like that.

don

Reply to
don

digitizing

in

Sir, I know programming in C. But I never programmed assembly program using C.

I don't have any past experience. Is it quite difficult to use the products I mentioned above? Please guide me appropriately. I wanted to save the digitized data to a text file in the PC.

-Kiran

Reply to
kiran_hk

digitizing

file in

Can that software help me to receive the data from the ADC module of PIC

18f452 to a text file in the computer? Kiran.
Reply to
kiran_hk

Which already tells me you either have a lot to learn about embedded programming (far too much for guidance) or have limited ability to use English to communicate accurately.

That's a problem. You need to start where you are at and move forward and you may need to admit that the task ahead of you needs to be set aside until you gain more appreciation of the details involved.

I know MPLAB and the PIC18F family to some degree. I don't consider them difficult.

But all of the details that surround taking samples and getting them loaded into a PC, while not necessarily difficult for someone with the experience... may be quite difficult for you, lacking experience.

Frankly, the tools you have, ICD 2 and MPLAB, are themselves fairly easy to use. It's possible that's your only problem -- learning to use them. But there are PDF files available for that and they are reasonably okay, if you simply read forward and follow instructions. I don't know what hardware bit you are using, except for the processor. But that really doesn't sound like your only problem.

If I had to set a path for you, it would be to start out getting a program running that can turn an LED on and off, slowly. Eventually getting to the point where you could blink an LED in such a way that doesn't appear to blink at all but instead appears to change in brightness, up and down, once say every 5 seconds. If you can get that much done, you are ready to start next into learning to use an ADC and store data somewhere.

It's possible that there is already a canned program to do what you want. I don't know what hardware blob you have and even if so, I'm still unaware of the program you might use without knowing how to program much.

You need to take some small steps, right now. Get some success there, first. Forget the project for a moment. What's the immediate problem in front of you? Do you know how to write any c code at all, get it downloaded to your target board, run the debugger on it, and trace through some results with understanding?

Jon

Reply to
Jon Kirwan

g

in

So you want to use the Debug system as a One-Off Data logger ?

I don't know about ICD 2 specifically, but usually separate terminal programs are included for data communication.

The better ones of these can save, and read from files.

The Debug systems task- focus is mainly to 'show you the registers', not to stream user ADC data.

So, see what virtual terminal support microchip offer, but usually it involves writing code to send your data to the serial port, and then (hopefully) your HW has a path already wired from that serial port, back to the PC.

-jg

Reply to
-jg

After you have programmed the FF kernel to the PIC, you can via the serial port experiment with how the PIC works.

Here is the Forth source code of how to read the AD converter on the PIC18F452. The Forth source is compiled into the PIC by typing it in on the command line, or be sending it from a file.

hex ram \ Define the PIC registers ffc4 constant adresh ffc3 constant adresl ffc2 constant adcon0 ffc1 constant adcon1 ff80 constant porta ff92 constant trisa

bin : adinit ( -- ) \ Init the registers 00111111 trisa c! 11001100 adcon1 c! 10000001 adcon0 c! ; hex

: ad@ ( channel -- n ) 3 lshift adcon0 c@ c1 and or adcon0 c! \ Select the AD channel pause \ Aquisition delay and possible task switch 4 adcon0 mset \ Start conversion begin 4 adcon0 mtst 0= \ Wait for conversion to complete until1 adresl @ \ Fetch the result ;

For example with the command " 1 ad@ " you can read the AD conversion result for channel 1 !

decimal adinit 1 ad@ . 1023

The converted value 1023 is returned on the parameter stack and printed with "." to the serial port.

If you want to read out many samples in a loop you define a new word for that. 'results' prints ad conversion values until a key has been pressed.

decimal \ Use decimal for compilation

: results decimal \ use decimal for output adinit \ Initialise the A/D converter. begin 10 ms \ 10 ms delay between each sample ad@ . \ Convert and output the ad conversion value key? \ Check for key press until key drop \ read and drop the keypress value ;

You can save the values into file from a terminal emulator with the capture function. Use for example TeraTerm as terminal emulator.

C is very nice and the 'standard' way of doing things, but with Forth you have command line interface with a interpreter and a compiler directly on the PIC.

IMHO, this makes learning the PIC functionality easier, because you can read and write the PIC registers from the command line and observe what happens directly without stopping the processor.

Reply to
Mikael Nordman

... snip ...

In my opinion you can't do embedded programming without understanding assembly coding for at least your object machine.

You have been omitting attribution lines for material you quote. Those are the initial lines that say "whozit wrote:", and the number of attribution marks (+1) identifies the appropriate lines.

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.