08-03-2019 02:20 PM
Hello everyone,
I have a device needs 10x period 80% PWM signal, 10x period 50% PWM signal and 10x period PWM Signal to activate sending serial data (baud rate 9600). How can I read the serial bitstream using a digital lines or counters (NI USB 6341). There’s an example program?
thanks a lot for your help in advance
08-04-2019 01:43 AM
Hi nbnnnbn,
Can you give a little bit more detail? In particular,
Please clarify what you're trying to do and I'm sure it should be straightforward enough to provide either a built-in example or a modified example here for you to look at.
08-04-2019 05:40 AM
Thank you for your replay.
I am sending PWM with 300Hz frequency and duty cycles. Device replay with sending back serial data at 9600 baud.
I want just to read this serial data (device response) using timed digital oi or counter.
08-05-2019 04:39 AM - edited 08-05-2019 05:36 AM
I'm using Digital input P0.5 to read bitstream at baud rate 9600. i have timing Problem. any suggestions?
08-05-2019 05:44 AM
Hi nbnnnbn,
i have timing Problem. any suggestions?
You have way more problems than just timing…
What's the point of this 10ms wait in the loop? Delete it! DAQmx will provide proper timing…
When you want to read your digital data you should sample at a higher sample rate! Ever heard of Nyquist and Shannon?
Why do you read a single bit, just to convert it to a 0/1 string?
Way to the solution:
- use a higher samplerate
- decimate the read data after syncing to your device.
- read more than just one sample per DAQmxRead call. (Good combinations would be 57600 S/s and 5760 samples to read…)
08-05-2019 05:49 AM
Is there any reason you cant just use a serial port to read back the serial data?
08-05-2019 05:56 AM
I'm with deceased - if this is something common like RS232 then there are many cheap and simple hardware solutions that will allow you to use things like the VISA Read node, and make the programming massively simpler.
If instead this is something more like SPI, then (although there are still hardware solutions) perhaps you have some more information to share - for example, do you also have a clock line? You could use that to control the rate of your data acquisition.
If for whatever reason those are unpalateable, then you can do it manually as suggested by GerdW with oversampling and then parsing in a similar way to what you uploaded. Follow the instructions given in his post and you should be fine 🙂
08-05-2019 08:50 AM
thanks a alot for your help. it works. i used Timing: Change Detection (See vi readSerialData.vi).
I have an other Question. i tried to create PWM signal using digital waveform:
frequency 300 Hz ±5
1. Duty cycle 80 ±5 (10 periods)
2. Duty cycle 50 ±5 (10 periods)
3. Duty cycle 10 ±5 (10 periods)
Problem is, i can not see the created PWM signal in Oscilloscope. the Amplitude of the signal is -+1V (desired range 0v-5v) in the analog Waveform Graph?? (Test120.vi )
sorry for my english 🙂
08-05-2019 08:57 AM
Hi nbn,
you forgot to attach the subVI of your "Test120" VI…
i can not see the created PWM signal in Oscilloscope.
Because you stop the DAQmx task immediatly after writing the digital data to the DAQmx output buffer!?
Wait until the DAQmx task is finished!
08-05-2019 09:09 AM - edited 08-05-2019 09:11 AM
thank you for your replay. how can wait until DAQmx task finish? i want to finish the task after sending PWM signals. i modified the Vi