Jump to content
  • 0

3XMCC 152 HATs on Raspberry Pi


seraph333

Question

9 answers to this question

Recommended Posts

  • 0
Just now, Jeffrey said:

The MCC 152 does not have any A/Ds so voltage input is not possible.

For the code for analog output, please see the example analog_out_write.py, included in the daqhats software found https://github.com/mccdaq/daqhats

Thanks, Jeffrey.

I should rephrase as how can I define the raspberry pi to give the MCC 152 a digital signal to output voltage.

I also has three MCC 134 HATs to take 6 thermocouples temperature, ADC to raspberry pi, compare with the input temperature, then use MCC 152 DAC to control power supply.

What is the code on raspberry pi to read the 6 thermocouples temperature? What is the code to give MCC 152 the signal.

 

Thanks a lot.

Link to comment
Share on other sites

  • 0

Measurement Computing provides you with a host of examples for each type of DAQHat.  They are included so that you can edit them to make them do what you want for your needs. When you purchase any of MCC products, It is assumed you know how to create an app or write a program in a supported app.  Not only are examples provided by also detailed documentation.  For the DAQhats etc the documentation is found here:  https://www.mccdaq.com/Manuals

I provided you with an additional example demonstrating how to read from 2, MCC 134s for a total of 8 TCs readings.  From that example you can expand on it to make read from any number (up to 8, MCC 134s).  

10 minutes ago, seraph333 said:

What is the code to give MCC 152 the signal.

As stated my my previous post, 

 

22 minutes ago, Jeffrey said:

For the code for analog output, please see the example analog_out_write.py, included in the daqhats software found https://github.com/mccdaq/daqhats

 

Link to comment
Share on other sites

  • 0
On 6/20/2022 at 10:26 AM, Jeffrey said:

Measurement Computing provides you with a host of examples for each type of DAQHat.  They are included so that you can edit them to make them do what you want for your needs. When you purchase any of MCC products, It is assumed you know how to create an app or write a program in a supported app.  Not only are examples provided by also detailed documentation.  For the DAQhats etc the documentation is found here:  https://www.mccdaq.com/Manuals

I provided you with an additional example demonstrating how to read from 2, MCC 134s for a total of 8 TCs readings.  From that example you can expand on it to make read from any number (up to 8, MCC 134s).  

As stated my my previous post, 

 

 

Thanks, Jeffrey.

Please excuse me as a newbie for python and Raspberry pi.

I try to write all analog out for 3 MCC 152 HAT, but there always problems to execute. Can you please help?

I have the file I modified attached.

Thanks a lot.

 

analog_output_write_allx3.py

Link to comment
Share on other sites

  • 0

Measurement Computing Application Engineers will answer focused questions on our software and hardware products.

As you are a self proclaimed newbie, I offer you the following:

Download and install Pycharm community edition, it is free.  Along with the DAQHats library and examples, it will fit on your Raspberry Pi with lots of room to spare.

Then load the example analog_output_write_all.py, and run it in debug mode so you can step through the example and see exactly where in the code new value(s) are written out to the DACs.

The error in the code you sent, was 2 fold.  You placed your code in the wrong place, and function call you used, 'a_out_write_all()' does not take the values you entered.

That function takes a 1D array ( or 'list' in python) of 2 values.

the line of code you are looking for is on line 102 or the original example.

Note there is no parameter for channel as that function writes 1 value out to each of the 2 DACs.

Don't forget to study the documentation:  https://mccdaq.github.io/daqhats/python.html#daqhats.mcc152.a_out_write_all

'Give a man a fish and he eats today.  Teach a man to fix and he eats for a lifetime.'

I'm teaching you how to 'fish'. 

Regards,

Jeffrey

Link to comment
Share on other sites

  • 0
21 hours ago, Jeffrey said:

Measurement Computing Application Engineers will answer focused questions on our software and hardware products.

As you are a self proclaimed newbie, I offer you the following:

Download and install Pycharm community edition, it is free.  Along with the DAQHats library and examples, it will fit on your Raspberry Pi with lots of room to spare.

Then load the example analog_output_write_all.py, and run it in debug mode so you can step through the example and see exactly where in the code new value(s) are written out to the DACs.

The error in the code you sent, was 2 fold.  You placed your code in the wrong place, and function call you used, 'a_out_write_all()' does not take the values you entered.

That function takes a 1D array ( or 'list' in python) of 2 values.

the line of code you are looking for is on line 102 or the original example.

Note there is no parameter for channel as that function writes 1 value out to each of the 2 DACs.

Don't forget to study the documentation:  https://mccdaq.github.io/daqhats/python.html#daqhats.mcc152.a_out_write_all

'Give a man a fish and he eats today.  Teach a man to fix and he eats for a lifetime.'

I'm teaching you how to 'fish'. 

Regards,

Jeffrey

Thanks, Jeffrey,

I appreciate for the material you provided. It's just at this stage I don't have that much time to start from beginning. I am strong on mechanical design side but not software.

I am trying to use all the AO to control a LED array.

Tried to modify the codes, but error just popup here and there, following is the code I am struck with, any little help to me is big.

def main():
    options = OptionFlags.DEFAULT
    channels = (0,1)
    hat0 = mcc152(0)
    hat1 = mcc152(1)
    hat2 = mcc152(2)
    
    for channel in channels:
        hat0.a_out_write_all(channel, get_input_values)
        hat1.a_out_write_all(channel, get_input_values)
        hat2.a_out_write_all(channel, get_input_values)

    address = select_hat_device(HatIDs.MCC_152)

    run_loop = True
    error = False
    while run_loop and not error:
        try:
            values = get_input_values()
        except ValueError:
            run_loop = False
        else:
            # Write the values.
            
            for hat in range(3):
                print('     ', hat, end='')
                if hat == 0:
                    for channel in channels:
                         hat.a_out_write_all(values=values, options=options)
                elif hat == 1:
                    for channel in channels:
                        hat.a_out_write_all(values=values, options=options)
                else:
                    for channel in channels:
                        hat.a_out_write_all(values=values, options=options)
            
            except (HatError, ValueError):
                error = True


if __name__ == '__main__':
    # This will only be run when the module is called directly.
    main()
 

Link to comment
Share on other sites

  • 0

  for channel in channels:
        hat0.a_out_write_all(channel, get_input_values)
        hat1.a_out_write_all(channel, get_input_values)
        hat2.a_out_write_all(channel, get_input_values)

should be:

  for channel in channels:
        hat0.a_out_write(channel, get_input_values)
        hat1.a_out_write(channel, get_input_values)
        hat2.a_out_write(channel, get_input_values)

I don't know if that will resolve your issue(s) but that is the one that stands out to me.

if you are getting any other errors, what is the error?

Link to comment
Share on other sites

  • 0
6 minutes ago, Jeffrey said:

  for channel in channels:
        hat0.a_out_write_all(channel, get_input_values)
        hat1.a_out_write_all(channel, get_input_values)
        hat2.a_out_write_all(channel, get_input_values)

should be:

  for channel in channels:
        hat0.a_out_write(channel, get_input_values)
        hat1.a_out_write(channel, get_input_values)
        hat2.a_out_write(channel, get_input_values)

I don't know if that will resolve your issue(s) but that is the one that stands out to me.

if you are getting any other errors, what is the error?

 First:

except (HatError, ValueError) as error:
    ^
SyntaxError: invalid syntax

Link to comment
Share on other sites

  • 0

 

On 6/24/2022 at 2:56 PM, seraph333 said:

First:

except (HatError, ValueError) as error:
    ^
SyntaxError: invalid syntax

I don't see an error.

Syntax error is a bad or wrong variable, bad or incorrect tab/spacing, or a type-o of some kind.

this same line of code is in the analog_output_write_all.py example at line 103.  That line is reporting there was a syntax error, not exactly where it is.  I recommend you study or step through the code to find the error.

I also recommend you review the example app analog_output_write.py.  This example is different than the one listed above as this one is for a single channel output.

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...