Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

vb6 sample code for flex_read_adc on flex motion

I'm have some trouble coding the flex_read_adc.  I enable the ADC's with flex_enable_adcs then call the read for channal 1.  I don't know how to read the vector (read(0))? and output it to a text box.  I didn,t find any examples on the knowlege base.
Thanks for your help
peter
0 Kudos
Message 1 of 8
(4,942 Views)
Hey peter,
 
You can use either the flex_read_adc16(u8 boardID, u8 ADC, u8 returnVector); function or the flex_read_adc16_rtn(u8 boardID, u8 ADC, i32* ADCValue); function to read the converted value from an ADC input channel. You can return the value into a few different places. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and don’t return data (0). The suffix _rtn on the function indicates that the data must be returned to the host. When this calling convention is used, no returnVector is required. Once you have the return data, you can display the data as you would display any other type of text or numeric in VB.
 
This information, and a lot more like it can be found in the NI-Motion Visual Basic Reference Help document that can be found by going to Start -> All Programs -> National Instruments -> NI-Motion -> Documentation and then choose the NI-Motion Visual Basic Reference Help. Then browse by Contents and go to the Functions, then look in the Analog and Digital I/O and you will find the functions that you will need to be able to read the values from you ADC's.
 
I hope this helps. Please let me know if you have any further questions or concerns. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 2 of 8
(4,915 Views)

Thanks for the info, but I can not find the NI-Motion Visual Basic Reference Help document that shows a short code example.  Is this on the NI Web site or in the Flex CD?  Also I havent seen the command: flex_read_adc16 or the flex_read_adc_rtn16.  I must have an older referance manual.  I'm still a bit confused....I'll work on it.

Thanks

peter

0 Kudos
Message 3 of 8
(4,912 Views)
Hey peter,
 
I appologize as I was assuming that you had the most recent version of the NI-Motion driver, which at the time of this post is NI-Motion 7.0. You can download this driver from the NI web site at the following link: Motion Control Drivers.
When you download this driver and install it, which I would highly recommend, then you will be able to choose to install the examples and documentation if you do a custom install. After you have done this, please let me know if you still cannot find the examples or the Help documentation that I mentioned in the previous post. Thanks, and have a great day.
 
Regards,
DJ L.
0 Kudos
Message 4 of 8
(4,892 Views)

DJ L.,

I installed Motion v7.0 and lost the capability to initialize the flex6 in max.  Max couldn't even see it.  Even though I made sure legacy support was installed.  Any Ideas?  Should I uninstall v7.0 and reinstall v5.1.1?

peter

 

0 Kudos
Message 5 of 8
(4,868 Views)
Hey Peter,
 
What hardware do you have? This will determine which software versions you will want to have installed. For now, go ahead and revert back to the driver that you originally had installed. What software did you have installed before, Valuemotion or Flexmotion?
 
Regards,
DJ L.
0 Kudos
Message 6 of 8
(4,834 Views)

I have had success in reading the ADC on the FlexMotion. It looks like this:

Private Sub Read_ADC_Click()

abort = False

'Set the range of the ADC's +/-10vdc (+/-2048)

status = flex_set_adc_range(boardID, ADC, NIMC_ADC_BIPOLAR)

 'This sets three ADC's active

 status = flex_enable_adcs(boardID, 3, 255)

 Do While (Cancel_ADC.Enabled = True)

 'Valid addresses for adc are &H51 To &H58 (1-8)

status = flex_read_adc_rtn(boardID. &H51, returnData)

ADC_Window.Text = returnData

Refresh

DoEvents

 If abort Then Exit Do Loop

End Sub

It was the mix of ASCII and Hex that made it work..I still can not make the FlexMotion work under v7 Motion Drivers. I still use V5.1.1 so making it work under Component Works 8 and VB.net might not be possible.  We invested quite a bit in these flex boards to bad their not supported under new software..they still work great.

Thanks

peter

0 Kudos
Message 7 of 8
(4,742 Views)

Just a thought...Has anyone recompiled FLEXMOTN.BAS, MotnCnst.bas, and MotnErr.bas under VB.net

Thanks peter

0 Kudos
Message 8 of 8
(4,738 Views)