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.

PIC 18F452 project help :(

Status
Not open for further replies.
Hi everyone! Before I begin, I would like to say that this is my first post, I am a complete novice and suck at this stuff! Basically I have a storage oscilloscope project that needs to do the following:

When the button PB1 is pressed, the program has to capture and store 1000 samples of a signal connected to an analog input terminal of the oscilloscope. When the capture process is complete, the program has to repetitively replay the samples on the oscilloscope via the analog output terminal (DAC channel A). The beginning of each replay cycle should be marked by a brief synchronizing pulse (DAC channel B).

There's a bunch of other info but I first want to see if anyone is interested in helping me, which would be very nice. I have attached the code that my lecturer has helped me with which is relevant but still doesn't do what it needs to.
 
A storage scope!.. For a first project!... Is your lecturer in a bad mood?

This is a big ask... The last time I got involved with an oscilloscope project... well, it didn't bode well.

The pic18f452 hasn't got a DAC output so the replay signal wont be the same as the input signal.....
 
Haha well first project technically but we've been doing tutorials every fortnight and let's just say they didn't bode well either.
The output will be generated from a thingy on the oscilloscope as I understand it
 
I understand what is required.......... signal in to scope......... store..... carry on to scope...

It's possible with a parallel DAC on an 8 bit port with frequencies up to about 2khz... I wouln't go any higher with this pic.... Download the scope tutorial from EPE magazine then modify the output to a DAC rather than the screen....
 
Haha well first project technically but we've been doing tutorials every fortnight and let's just say they didn't bode well either.
The output will be generated from a thingy on the oscilloscope as I understand it

What the eff. First project and already this? What has the world come to?

You're going to need a PIC with both a Analog to digital converter (ADC) and a Digital to Analog Converter (DAC). WHich kind of PIC, you'll have to search on the Microchip side. I assume you'll want to stick to the PIC18 family.

Hints
Although you could determine the state of PB1 by testing bit 1 of PORTB, it's much easier to write the code if you instead test the INT1 interrupt flag bit (in register INTCON3). The latter approach is simpler because the flag is set when the button is pressed and remains set until you explicitly clear it. To make the flag sensitive to the falling edge (the pushbuttons are active low), you'll need to set the appropriate edge polarity (in INTCON2). The simplest way to store and retrieve the signal samples is using indirect addressing. At the beginning of a capture or replay cycle, load one of the file select registers (FSR) with the address of the beginning of the data block where the samples are stored, then use the appropriate POSTINC register so that the address is automatically incremented after each reference. The structure of your program will be simplest if you use interrupts to manage the capture and replay timing. Configure a timer to generate interrupts at the sample rate, then write an interrupt handler that will process a single sample. You'll need to devise a way for the handler to know whether the program is in capture or replay mode. You'll probably find it most convenient to use timer 2 to generate the timing, because you can use its period register to fine-tune the timeout length to exactly 100 μs.

THis is actually pretty helpful...if you know what your lecturer means by PORTB, INT1, INTCON3 and all the fancy stuff. You're going to need to read about interrupts, timers, ADC and DAC. I've done all of them on a 16F877A except DAC which the F877A doesn't support. Read the datasheets; it's ahuge help.
 
The 18F452 doesn't have a DAC and so I'm guessing it's external hardware. Do you have a schematic of the PicTrainer board? The chip also has only 1.5K of ram and so storing 1000 x 10 (1250 bytes) bit samples is going to be challenging. What language do you have to write this in?

Mike.
 
Yes the DAC is external hardware and no I don't have a schematic of the trainer board. The lecturer did say that we would have to find a way to store the 1000 samples in 2 different locations. Were writing this in assembly code and we're using MATLAB. I know what I need to do, I just don't know how to do it. Writing interrupts and interrupt handlers and what not is beyond me..
 
Like I said in post #4... John Bekker (RIP) made a simple storage scope... (The same as you require) for the EPE magazine " MAY 2001 " ..

Download the zip file ( it's in assembly ) and just have a look.... The code needs porting to the pic18f452 but atleast you'll get the idea.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top