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.

A Microcontroller based Analogue Waveforms Analyzer Project

Status
Not open for further replies.
samcheetah said:
PIC assembler only has 35 commands (and many of those are rarely used), so it's not too hard to learn

is that for all the PIC microcontrollers?

and if i want to learn the assembly commands of PICs where should i start from (in addition to your tutorials)

Not for all, that's for 14 bit core PIC's (the most popular ones), 12 bit core only have 33 commands, and (I think) 16 bit core have 55.

I would suggest printing the datasheet out for a start, the 16F628 is probably the best to start with (which I why I choose if for the tutorials). It also includes all the commands, along with lots of device specific information which is important to know.

I always think the best way to learn is by copying other peoples code, and modifying it to make it do what you want. That's the basis behind my tutorials - by modifying existing code (and finding out it doesn't work anymore!) you learn a lot about how it works. It's very gratifying when you do actually get your mods to work :lol:

One big problem with anything program based, is when it doesn't work - is it a hardware problem?, or a software problem?. This is why I give veroboard layouts, and proven working software - by building exactly as shown, and using my routines, it WILL WORK. Then when you modify it, you know the hardware is OK - as you've already seen it working.
 
PIC Assembler Commands

PIC assembler only has 35 commands (and many of those are rarely used), so it's not too hard to learn

Are you mean these 35 commands from the figure below? :roll:
 

Attachments

  • pic_assembler_commands.gif
    pic_assembler_commands.gif
    18.3 KB · Views: 882
Re: PIC Assembler Commands

km said:
PIC assembler only has 35 commands (and many of those are rarely used), so it's not too hard to learn

Are you mean these 35 commands from the figure below? :roll:

Yes, they are the ones 8)

If you look at my first tutorials you will see how few of them you need to actually do something.
 
Analogue Circuitry Diagram

This is the circuit that I found on the internet. Its purpose is to ensure the input voltage to the ADC falls between 0 to 5V. 8)

From the figure below, the first op-amp is designed to change the input voltage so that it does not go over zero volts, for example changes -2.5 to 2.5V, to -5 to 0V. The second op-amp is configured in negative amplifier mode with a gain of unity changing -5 to 0V to 0 to 5V. The third part with the two diodes is for protection, e.g. say a -1 to 6V signal makes it through the op-amps the diodes will cut off the peaks of the waveform making sure no damage is done to the A2D.
:arrow:
Can this circuit able to operate for the largest input voltage range -250V to 250V :?:

Is this circuit sufficient for my project at the input stage? (to step down the input voltage to 0-5V) :roll:

Should I used any variable resistors? :!:

Instead of 3 inputs, can I have only one? (i.e. to select different range of voltage) If can, HOW? :idea:

Just remembered something I forgot, you will need a low-pass filter on the input stage, it's vital that your sampling rate is higher then the maximum incoming frequency - at least double, preferably more!. Otherwise you get anti-aliasing distortion which will complete ruin any readings.

The low-pass filter that Nigel had mentioned, where do I need to put? Before this circuit OR between this circuit and the A2D?
 

Attachments

  • analogue_circuitry.gif
    analogue_circuitry.gif
    4.4 KB · Views: 561
Re: Analogue Circuitry Diagram

km said:
This is the circuit that I found on the internet. Its purpose is to ensure the input voltage to the ADC falls between 0 to 5V. 8)

From the figure below, the first op-amp is designed to change the input voltage so that it does not go over zero volts, for example changes -2.5 to 2.5V, to -5 to 0V. The second op-amp is configured in negative amplifier mode with a gain of unity changing -5 to 0V to 0 to 5V. The third part with the two diodes is for protection, e.g. say a -1 to 6V signal makes it through the op-amps the diodes will cut off the peaks of the waveform making sure no damage is done to the A2D.

If you're using a PIC A2D, you don't need the protection diodes, they are already built-in to the PIC.

Can this circuit able to operate for the largest input voltage range -250V to 250V :?:

Yes, no problem - but make sure the 100K resistor on the input is suitably rated.

Is this circuit sufficient for my project at the input stage? (to step down the input voltage to 0-5V) :roll:

Yes.

Should I used any variable resistors? :!:

As long as you use 1% resistors, you shouldn't need any.

Instead of 3 inputs, can I have only one? (i.e. to select different range of voltage) If can, HOW? :idea:

Just include the input resistors for the value you want, leave the rest out.

Just remembered something I forgot, you will need a low-pass filter on the input stage, it's vital that your sampling rate is higher then the maximum incoming frequency - at least double, preferably more!. Otherwise you get anti-aliasing distortion which will complete ruin any readings.

The low-pass filter that Nigel had mentioned, where do I need to put? Before this circuit OR between this circuit and the A2D?

You could make the second opamp stage into a lowpass filter, as long as it inverts - if you use a non-inverting filter, you could add it either before or after the second opamp.
 
Confirmation

Sorry!! I think I have missed out some qustion. :shock: For the analogue circuitry diagram (as shown in previous post), is it necessary to include the capacitor C1 in the circuit (last part of the circuit)? If YES, is it acceptable for 100µF?

As for the low pass filter - RC circuits, is it acceptable for R=1000kΩ & C=1µF ? If it is not acceptable, can you please suggest suitable values for me? Is the resistor for the RC circuit has to be 1% resistor?

Thank You!! :wink:
 
Re: Confirmation

km said:
Sorry!! I think I have missed out some qustion. :shock: For the analogue circuitry diagram (as shown in previous post), is it necessary to include the capacitor C1 in the circuit (last part of the circuit)? If YES, is it acceptable for 100µF?

100uF would be far too big, you don't need a capacitor there at all, a PIC A2D already has a sample and hold capacitor.

As for the low pass filter - RC circuits, is it acceptable for R=1000kΩ & C=1µF ? If it is not acceptable, can you please suggest suitable values for me? Is the resistor for the RC circuit has to be 1% resistor?

It all depends on how fast you are going to read the incoming signal, a simple resistor capacitor filter is probably not good enough, you should make the 2nd opamp into an active filter at about 1/5th of your sampling rate.
 
Re: Confirmation

Thanks for your advice, Nigel!! :wink:

100uF would be far too big, you don't need a capacitor there at all, a PIC A2D already has a sample and hold capacitor.

I used PIC 16F628 (without a built-in A2D), so is it means that I don't need the capacitor as well? I'm using an external A2D (TLC 548).
 
Re: Confirmation

km said:
Thanks for your advice, Nigel!! :wink:

100uF would be far too big, you don't need a capacitor there at all, a PIC A2D already has a sample and hold capacitor.

I used PIC 16F628 (without a built-in A2D), so is it means that I don't need the capacitor as well? I'm using an external A2D (TLC 548).

If you check the datasheet it will tell you, as far I know it should have an internal sample and hold.
 
Confirmation of my project

PART 1:

km said:
As for the low pass filter - RC circuits, is it acceptable for R=1000kΩ & C=1µF ? If it is not acceptable, can you please suggest suitable values for me? Is the resistor for the RC circuit has to be 1% resistor?

Nigel Goodwin said:
It all depends on how fast you are going to read the incoming signal, a simple resistor capacitor filter is probably not good enough, you should make the 2nd opamp into an active filter at about 1/5th of your sampling rate.

In that case, do I need to use a variable resistor for my active low pass filter design? (for the 2nd opamp)

PART 2:

Nigel Goodwin said:
Using PIC 12F675 with a built in ADC is not allowed also.(since the condition clearly stated: No built-in ADC PIC allowed!!) I am planning to used TLC 548 A2D (8-bit resolution), is that good enough for my project
Should be fine, 8 bits is plenty.

For my project, do I need to built an extra circuit before feeding the A2D output to the PIC 16F628? Because the data from the A2D is going to be very difficult to analyze and I might have difficulty in obtaining the results (i.e. frequency, average, peak-to-peak).

As for the external A2D I used (TLC 548), from what Nigel had said:"it should be fine to use that". (But from what I heard, the accuracy required for such applications is critical) Am I able to get accurate results with the external A2D (TLC 548)? Should I consider another A2D chip? (maybe an A2D 10-bit resolution):?:

PS:I'm getting more worry about my project day by day as I only left 2 months to do my project :cry:
 
Re: Confirmation of my project

km said:
In that case, do I need to use a variable resistor for my active low pass filter design? (for the 2nd opamp)

Only if you want to make it variable.

PART 2:

For my project, do I need to built an extra circuit before feeding the A2D output to the PIC 16F628? Because the data from the A2D is going to be very difficult to analyze and I might have difficulty in obtaining the results (i.e. frequency, average, peak-to-peak).

No, the output from the A2D will feed directly into the PIC, you just need to write the software to control it.

As for the external A2D I used (TLC 548), from what Nigel had said:"it should be fine to use that". (But from what I heard, the accuracy required for such applications is critical) Am I able to get accurate results with the external A2D (TLC 548)? Should I consider another A2D chip? (maybe an A2D 10-bit resolution):?:

As I see it you are going to have to perform considerable calculations on the incoming data - I would suggest you write a program on the PC to perform these calculations and feed it dummy data, that way you can confirm it works, and check what resolution will suffice. There's no point building hardware when you don't even know if it will be possible or not.

If you've only got two months to complete this, and you don't appear to have started work yet, I would suggest a lot of prayer might be in order :roll:
 
:shock: A lot of prayer? LOL :lol: Thanks for your advice!!

Nigel Goodwin said:
I would suggest you write a program on the PC to perform these calculations and feed it dummy data, that way you can confirm it works, and check what resolution will suffice.

How can I do that? What software do I need? :idea:
 
km said:
:shock: A lot of prayer? LOL :lol: Thanks for your advice!!

Nigel Goodwin said:
I would suggest you write a program on the PC to perform these calculations and feed it dummy data, that way you can confirm it works, and check what resolution will suffice.

How can I do that? What software do I need? :idea:

Write in whatever software you are experienced in, Delphi, BASIC, C, Pascal, Prolog, Java - any language you like, just to prove it works, and to test what resolution works best. I would expect this sort of pre-planning and testing to be part of your documentation, and it all helps towards good marks.

You also have the problem of how many samples you need to give a sufficiently accurate reading - this is further compounded by the lack of RAM in mid-range PIC's. An obvious easy value (for an 8 bit processor) would be 256 samples, but you don't have anywhere to store them in a 16F84. Again, you can use the PC to test different numbers of samples, to see how few you can get away with - and again, this should all be documented.

If you look on the PICList there's a project for performing FFT (Fast Fourier Transforms) using a PIC, but it uses a high end PIC, with lots more memory and more power.
 
Not PIC 16F84

Nigel Goodwin said:
You also have the problem of how many samples you need to give a sufficiently accurate reading - this is further compounded by the lack of RAM in mid-range PIC's. An obvious easy value (for an 8 bit processor) would be 256 samples, but you don't have anywhere to store them in a 16F84. Again, you can use the PC to test different numbers of samples, to see how few you can get away with - and again, this should all be documented.

I had changed my decision to use PIC 16F628 (It's your opinion 8) ). Will it has the same problem as what you have said?
 
Yes, 16f628 only has 224 byte of ram, still not enough (you're probabely need some of that for the rest of the software, not all ram can be used to store samples)
 
Re: Not PIC 16F84

km said:
I had changed my decision to use PIC 16F628 (It's your opinion 8) ). Will it has the same problem as what you have said?

I agree with Exo, I suspect you would be better off with a high range PIC (18F series). But first, as I've already mentioned, try running it on a PC, and see how many samples you need to calculate what you are wanting to do - you 'might' be surprised.
 
PIC 16F87 OR PIC16F648A

Exo, thanks for spending your time to read my post!! :wink:

Exo said:
Yes, 16f628 only has 224 byte of ram, still not enough (you're probabely need some of that for the rest of the software, not all ram can be used to store samples)

If in that case, which PICs should I used? (without a built-in A2D)
How about PIC 16F87 OR PIC16F648A? Both of these have twice the program space as the PIC 16F628. :idea:
 
PIC 16F87 OR PIC16F648A

Exo, thanks for spending your time to read my post!! :wink:

Exo said:
Yes, 16f628 only has 224 byte of ram, still not enough (you're probabely need some of that for the rest of the software, not all ram can be used to store samples)

If in that case, which PICs should I used? (without a built-in A2D)
How about PIC 16F87 OR PIC16F648A? Both of these have twice the program space as the PIC 16F628. :idea:
 
Do the preliminary work first, and find out what you need - then look for a processor which will fit those requirements. No point in choosing a processor to find out later it won't do what you want.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top