Jump to content
  • 0

Example Python code for configuring PWM on USB-CTR04


DAQNoob

Question

Hi,

I thought I could reuse PWM code from a USB-1608G module in the USB-CTR04 but get a ULError "Invalid counter device".

Is this expected? I was under the impression that the USB-CTR04 had an internal timebase, like the USB-1608G does for PWM generation on TMR0.

If it doesn't, is there example python code to show how to configure the USB-CTR04 for PWM generation on TMR0-3?

Update: I was able to configure TMR0 on two USB-CTR04 modules as done on the USB-1608 but TMR1/TMR2 (same config) are not working.

I think my issue is in understanding external/internal port/channel mapping. If I am reading the internal channel config correctly:

for channel in ctr_info.chan_info:
    if channel.type == CounterChannelType.CTRPULSE:
        print(f'CTRPULSE Channel(s): {channel.channel_num}')

CTRPULSE Channel(s): 0 CTRPULSE Channel(s): 1 CTRPULSE Channel(s): 2 CTRPULSE Channel(s): 3

map to TMR0-3

Edited by DAQNoob
Additional info...
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

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