Jump to content
  • 0

MCC 152 and MCC 128


Youmin

Question

Hi,

 

I am trying to stack MCC152 and MCC128 together onto one RPI since my system has both analog output and analog input. May I know whether that's something doable? Will that mess up with the GPIOs?

 

Thanks.

Edited by Youmin
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thank you Jeffrey! I am trying to run a continuous sinusoidal output from MCC152. May I ask whether there's any example code for that? I am thinking of using "sleep()" function achieving that but concerned it may slow the IO speed.

 

I also saw the maxumum output speed is 5kS/s for MCC152. Is there approaches if I want to output faster frequency signal? Thanks.

Link to comment
Share on other sites

  • 0

Keep in mind, the MCC 152 is not capable of streaming output data at a uniform rate.  There is no analog output scan function for this device.  Instead you must manage the clock timing on your own.

The main algorithm for generating a sine wave and writing out each value as generated:

for i = 0 To (360- 1)
        OutputValue = MaxAmplitude * Sin((i * (2 * PI / 360))) + DCOffset   //'# create a sine wave in 2PI radians .

        mcc152_a_out_write(address, 0, AoOptions, OutputValue)
 Next 

Where:

MaxAmplitude is the max voltage out for your sine wave, such as 5V peak to peak sine wave.

DCOffset is where you want the 'zero crossing' level to be.  Normally it is set to 0.

I ran some benchmarks of my own for the MCC 152, outputting alternating 0V and 5V as fast a possible. Or in other words, the app I used toggled between 0V and 5V on one channel, doing nothing more that that.  It did not display anything on the screen because that would slow down the output update rate.

My results:

C/C++:  56.4 k writes per second.

python 3.x:  33 k writes per second.

givens: Raspberry pi 3B

GNU C and CodeBlocks.

Your results may vary.

Having stated that, and using the C test result, the maximum sine wave you can output if you use 360 distinct points (of the sine wave):

Max Freq = 56,400 writes per second / 360 points per period

Max Freq = 151.6 Hz sine wave.

"Is it possible to output a higher frequency sine wave (ie make it go faster)?"  Yes, but the sine wave form may suffer.  You can decrease the number of points per period from 360 to 180:

for i = 0 To (180- 1)
        OutputValue = MaxAmplitude * Sin((i * (2 * PI / 180))) + DCOffset   //'# create a sine wave in 2PI radians .

        mcc152_a_out_write(address, 0, AoOptions, OutputValue)
 Next 

Applying the same math, you can output a 303.3 Hz sine wave.  but keep in mind it will look a bit like a staircase.

Or, at 90 points per sine wave period : ~606 Hz.

You can continue to reduce the number of points per sine wave period, but when you get to < 60 points per period, it no longer looks much like a sine wave.

Note: the MCC 152 outputs values statically,  i.e. one at a time. if you look at the values on an oscilloscope, you will see individual DC levels.  Should you prefer a smooth sinewave you will need to add some filtering or smoothing.  Easiest way to do that is with RC filter.

While the MCC 152 is capable of outputting periodic signals, that was not the designed intent.  the designed intent was to just output DC level signals, it just so happens you can change the DC level at a fairly robust rate.  So if you want to acquire data using the MCC 128 AND output a sine wave, you will see lags in the sine wave when you are servicing the MCC 128 (to off load data or make decisions on the collected data).

Regards,

Jeff

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...