Help Need Please On DA System

yeezhihao

New Member
Dear all

Before I make my purchase of the PicAxe8m, can I just ask a few questions to ensure that its able to perform what I want it to do. By the way, I'm a real noob in such stuffs, so please bear with me should I happen to make any stupid statements.

I wish to build a DA system, and the first part of it is done via the usual op-amps and filters.

Currently, I would like to hook up the o/p from the filter to an ADC and have the converted bits passed to a serial output; which would eventually make use of a bluetooth module to send these bits to a PC/Mobile Device.

I understand that the 8m comes with a 10bit ADC, however, I was wondering if this ADC already has a sample/hold circuit embedded in it? Also, what is the max frequency that this ADC can sample? As too low sampling rates may cause aliasing to occur based on Nyquist theory. Are there any other inputs which I must hook up for the ADC to function, like Vref??(not too sure how exactly the ADC works, would appreciate if someone cld clarify)

Should the ADC work as expected, the 10bits would then be "passed" to the serial output for serial transmission.

Based on what I have gather from some of the sample codes, I observed that the ADC would usually output the values in decimal instead of binary, is this always the case? Should it always output the values in decimal, would there be any problems when it comes to transferring the values to the serial out? How does serial port converts the decimal to binary bits again?

Last but not least, and actually most importantly, would this MCU be able to perform what I have described based on your experience?

I thank you for your time and appreciate your prompt reply.:)

Cheers!
Zhihao

Edited section: Oh yes, could anyone point out the direction for a detailed PicAxe data sheet which might contain information like ADC type, propagation delays, timing diagrams etc?? Cause I can't seem to find these detailed sheets anywhere! Thanks a zil!
 
Last edited:

Dippy

Moderator
I don't petend to know what a DA system is, but the effective sampling rate will not be very high. (A few thousand sps?). Certainly not hi-fi and you'd need a good filter to cut down anti-aliasing. And if you were serially o/ping after each sample then much slower as it can't buffer (though I don't whether any POKERS have achieved it?)

I don't think any PICAXE Data Sheet shows that info (??). Whilst the actual ADC Conversion command execution speed will be based on the particular PIC (see Microchip Data Sheet), the interpreter time is the major part of the speed equation.

However, it is very easy to use and very cheap to buy and try but (diplomatically) I suspect it's not really the right Horse for this Course. I know what maybe but I'll keep shtum.
 

yeezhihao

New Member
I don't petend to know what a DA system is, but the effective sampling rate will not be very high. (A few thousand sps?). Certainly not hi-fi and you'd need a good filter to cut down anti-aliasing. And if you were serially o/ping after each sample then much slower as it can't buffer (though I don't whether any POKERS have achieved it?)

I don't think any PICAXE Data Sheet shows that info (??). Whilst the actual ADC Conversion command execution speed will be based on the particular PIC (see Microchip Data Sheet), the interpreter time is the major part of the speed equation.

However, it is very easy to use and very cheap to buy and try but (diplomatically) I suspect it's not really the right Horse for this Course. I know what maybe but I'll keep shtum.
Actually I should not be too worried about the sampling capabilities as my signals are cut off at about 150Hz, maybe lesser. If thats the case, the max time that ADC can take to convert my signal is : 1/(2^n*pi*fsig)
which is about 2microSec. 2microSec in modern ADCs is a very long time, but am not too sure if this is the case for the PicAxe.

Hey, mind if i pop another question? Am I correct to say that the PicAxe serial out is "equipped" with UART? Or is not??(which means I have to hook up the serialout to a Max232??)

Haha...maybe u'll like to provide some clues to wat MCU tat might be?? *hints hints*

Btw, if I were to consult the PicAxe technical staffs, would you have any idea what are the chances of them replying to my query on the max frequency the ADC can sample?

Thanks dude.
 

BeanieBots

Moderator
Suggest you have a read of the PIC 12F683 datasheet which is what the 08M is based on. It expalins the sample-hold used by the chip istself.
Vref comes from the power rail.
The ReadADC command takes about 250uS to execute at normal clock speed.
Serial out supports both true and inverted so you will only require a MAX232 if you need the full +/-12v drive.
 

hippy

Senior Member
Actually I should not be too worried about the sampling capabilities as my signals are cut off at about 150Hz, maybe lesser. If thats the case, the max time that ADC can take to convert my signal is : 1/(2^n*pi*fsig)
which is about 2microSec
It might be possible to do an ADC in 2uS, but you won't ever get that sort of throughput from a PICAXE. At 8MHz operation, each instruction takes around 150uS, so that's 150uS for the READADC, 150uS to send the data out and another 150uS to go round the loop. At 9600 baud it's going to take 1100uS to actually send the data.

The fastest loop time is going to be around 1500uS, so you may be able to take approximately 660 8-bit samples per second. You can halve that if you need 10-bit samples.

These figures are all approximate but hopefully in the right ballpark. You probably won't get a better response from Technical / Rev-Ed than in the forums.

I didn't really understand about your signals being cut off at 150Hz; if you need less than 660 or so 8-bit samples per second then you should be okay with a 08M. We'd really need to know what sample rate you are looking for to suggest a practical PICAXE solution, actual ADC conversion time is quite an insignificant part of the equation when it comes to the PICAXE.
 

yeezhihao

New Member
It might be possible to do an ADC in 2uS, but you won't ever get that sort of throughput from a PICAXE. At 8MHz operation, each instruction takes around 150uS, so that's 150uS for the READADC, 150uS to send the data out and another 150uS to go round the loop. At 9600 baud it's going to take 1100uS to actually send the data.

The fastest loop time is going to be around 1500uS, so you may be able to take approximately 660 8-bit samples per second. You can halve that if you need 10-bit samples.

These figures are all approximate but hopefully in the right ballpark. You probably won't get a better response from Technical / Rev-Ed than in the forums.

I didn't really understand about your signals being cut off at 150Hz; if you need less than 660 or so 8-bit samples per second then you should be okay with a 08M. We'd really need to know what sample rate you are looking for to suggest a practical PICAXE solution, actual ADC conversion time is quite an insignificant part of the equation when it comes to the PICAXE.
Hey, u are absolutely right!
I mixed up bandwidth and throughput!

What i calculated was bandwidth, I should have used throughput instead!
You have enlightened me!!! Thank you so very much!!

Based on your (pretty conservative) calculation, the ADC in PicAxe will DO THE JOB!!

Really thanks for pointing out my mistake!! Appreciate it.
 

Dippy

Moderator
Well I'm confused. I know it's not difficult.
If your cutoff is at 150Hz I cannot see your calc for 2 microseconds. I've written PIC 'scope software and used much slower sampling rates for 150Hz. But as I don't know precisely how you want to code-up then I've probably missed a bit of the plot.
And you'd have to go to dsPICs to get a 'cheap' MCU to sample much faster than 2 microseconds - how's your 'C'?

I can't remember whether hippy had a Poke for the USART on smaller PICAXEs or I assume the X1 has the Hserout. Is that right hippy I've never used it?
(Does the firmware wait for TX buffer to empty before continuing?)

And in many cases you don't need MAX232, in fact a simple 2 transistor circuit can replace MAX232.

"Haha...maybe u'll like to provide some clues to wat MCU tat might be?? *hints hints*"
- sorry , dude, I don't understand.


Maybe if you explain your setup with a posted schematic then someone can give some pukka answers. And also the flow diagram for your desired code would be very useful.
It's tricky as you know what you want and we're half-guessing though I'm very impressed with the use of Nyquist theory.
 

hippy

Senior Member
I can't remember whether hippy had a Poke for the USART on smaller PICAXEs or I assume the X1 has the Hserout. Is that right hippy I've never used it?
(Does the firmware wait for TX buffer to empty before continuing?)
The 18, 18X, 28X and 40X have UART's which can be poked to, but not the smaller PICAXE's. It adds extra execution time to do the poking but should be an overall advantage. X1 devices probably do check the TX buffer is available before sending, but at higher baud rates the execution times of PICAXE instructions usually means it will be when it comes to poking the next byte so often no check is needed.

The advantage of a poke to UART is that there's less work for the Firmware than decoding pin and baud rate of the SEROUT. On that point, SEROUT may be longer than 150uS so that will reduce throughput. Using SERTXD on Pin 0 would probably help there.

Anyone got a scope and 08M setup ? It would be interesting to see at what rate data is sent out ( pin 1 can be left floating ), and would go a long way to answering the original question -

Code:
SetFreq M8
Do
  ReadAdc 1,b0
  SerTxd( b0 )
Loop
 

hippy

Senior Member
Very many thanks for that fgnash, much appreciated.

That works out at 588 samples per seconds. That's an average of 200uS per command @ 8MHz, 400uS @ 4MHz.
 

yeezhihao

New Member
Very many thanks for that fgnash, much appreciated.

That works out at 588 samples per seconds. That's an average of 200uS per command @ 8MHz, 400uS @ 4MHz.
sorry for the late reply, was away for few days.

with regards to fgnash's results, i'm sure the ADC is capable of sampling frequency of much higher than (1/1.78 * 10^-3).

As this time is the total time required for the propagation delay of read signal to ADC(which i believe occurs internally w/o the knowledge of user), time to convert, propagation delay of write signal to ADC, time to write the converted result to some location, time to send the bits to the serial port as well as time to perform Instruction fetch, Instruction decode, execute and any possible write back.

fgnash: i presume that is the time taken for 8bits ADC and not 10?
 

yeezhihao

New Member
Well I'm confused. I know it's not difficult.
If your cutoff is at 150Hz I cannot see your calc for 2 microseconds. I've written PIC 'scope software and used much slower sampling rates for 150Hz. But as I don't know precisely how you want to code-up then I've probably missed a bit of the plot.
And you'd have to go to dsPICs to get a 'cheap' MCU to sample much faster than 2 microseconds - how's your 'C'?

I can't remember whether hippy had a Poke for the USART on smaller PICAXEs or I assume the X1 has the Hserout. Is that right hippy I've never used it?
(Does the firmware wait for TX buffer to empty before continuing?)

And in many cases you don't need MAX232, in fact a simple 2 transistor circuit can replace MAX232.

"Haha...maybe u'll like to provide some clues to wat MCU tat might be?? *hints hints*"
- sorry , dude, I don't understand.


Maybe if you explain your setup with a posted schematic then someone can give some pukka answers. And also the flow diagram for your desired code would be very useful.
It's tricky as you know what you want and we're half-guessing though I'm very impressed with the use of Nyquist theory.
dippy

u are absolutely correct, the 2mircosecond derivation was incorrect.
I calculated bandwidth instead of throughput, thus, having a very different answer. ;)

thnx for the info of how to use a transistor to replace Max 232.:)

For the flow diagram, i don't have it yet as i have not bought the MCU and the start up kit... I wanted to first verify that the MCU could handle my needs before i go ahead and buy one...

I see many of you using the term "POKE" here, pardon me for my ignorance but is the POKE command used for writing to a memory location?? And what has POKE got to do with UART??:confused:
 

Dippy

Moderator
I haven't got a Data Sheet in front of me to give you numbers, but I suggest you download a few from Microchip.
You will see that many functions (e.g. setting a pin as input or output , or enabling the UART) are allocated as registers. By writing a value into these registers you can adjust these settings or, in the case of the UART, put a number into the output Tx buffer for serial transmission. There are many registers that can be adjusted - some with caution mind.
The method varies with the language used; in PICAXE you would use POKE to shove a certain value to a certain location.

I'm sure some kind soul can provide examples as I can never remember numbers of the top of my head. If the same kind person can give examples then you have a look in the Microchip PIC Data Sheet to see what it does. IT WILL require READING and UNDERSTANDING on your part. You'll get the hang of it after a while, and then you will see how useful it all is and how it will expand your programming skills.
 

yeezhihao

New Member
I haven't got a Data Sheet in front of me to give you numbers, but I suggest you download a few from Microchip.
You will see that many functions (e.g. setting a pin as input or output , or enabling the UART) are allocated as registers. By writing a value into these registers you can adjust these settings or, in the case of the UART, put a number into the output Tx buffer for serial transmission. There are many registers that can be adjusted - some with caution mind.
The method varies with the language used; in PICAXE you would use POKE to shove a certain value to a certain location.

I'm sure some kind soul can provide examples as I can never remember numbers of the top of my head. If the same kind person can give examples then you have a look in the Microchip PIC Data Sheet to see what it does. IT WILL require READING and UNDERSTANDING on your part. You'll get the hang of it after a while, and then you will see how useful it all is and how it will expand your programming skills.
Yup...will get hold of the MCU and play around with it...I'm sure it will not be too difficult. I have worked with Intel8051 and HitachiH8 MCU(based on embedded C) before, so i guess they are pretty much the same... like setting registers and timers to achieve the system needs...
 
Top