Difference between revisions of "826"

From Sensoray Technical Wiki
Jump to: navigation, search
(Counters: +basic encoder programming)
(+dio pulse bursts)
Line 20: Line 20:
 
When a snapshot is caused by counts equal to a compare register, the snapshot counts will always be equal to the compare register value.
 
When a snapshot is caused by counts equal to a compare register, the snapshot counts will always be equal to the compare register value.
  
===How to read incremental encoders===
+
===Programming for incremental encoders===
  
 
''Which functions should I use for incremental encoders?''
 
''Which functions should I use for incremental encoders?''
Line 28: Line 28:
 
First configure and enable the counter channel:
 
First configure and enable the counter channel:
  
    Call S826_CounterModeWrite() with mode=0x00000070
+
Call S826_CounterModeWrite() with mode=0x00000070
    Call S826_CounterStateWrite() with state=1
+
Call S826_CounterStateWrite() with state=1
  
 
To read the current encoder counts:
 
To read the current encoder counts:
  
    Call S826_CounterRead()
+
Call S826_CounterRead()
 +
 
 +
==DIOs==
 +
 
 +
===Generating a burst of pulses===
 +
 
 +
''How can I make a DIO channel go active for 10ms and then inactive for another 10ms, and repeat this five times?''
 +
 
 +
There are many ways to do this but the methods you can use depend on a number of factors. Here are two general strategies:
 +
 
 +
1. If high precision is not needed you can call S826_DioOutputWrite() multiple times, with 10ms software delays between the calls. The precision of this method depends on your operating system and system load. The code for this method is simple and straightforward.
 +
 
 +
2. If you need precise timing then you could use two counter channels. For example, using counter channels 0 and 1:
 +
 
 +
* Counter 0: Configure as PWM generator with 10ms on/off times, with external enable. Connect its enable input to counter 1's output. The goal here is for counter 0 to enable counter 1 to output pulses; counter 0 will enable the PWM generator until 5 pulses have been generated.
 +
* Counter 1: Configure as event down-counter, with preload (value=5) upon enable, with external clock, with output active when counts not zero. Connect its clock input (must be external connection) to counter 0's output. The goal here is for counter 1 to count PWM pulses until it counts from 5 down to 0; it will then set its output low, thus disabling the PWM generator.

Revision as of 11:47, 27 March 2014

Contents

ADC

Calibration errors caused by missing shunt

On 826 SDKs earlier than version 3.2.0, analog calibration values will not be applied without J6 (labeled "Calibration Enable") installed. A missing shunt is intended to protect against accidental overwriting of calibration values, but in these SDKs it also prevents the reading of those values. This is resolved in SDK version 3.2.0 and above; in these versions the shunt functions as intended and must be installed only when calibrating the board (though leaving it installed all the time is okay).

If board calibration is incorrect, make sure J6 is installed or upgrade to SDK version 3.2.0 or higher. The 826 SDK can be downloaded from the 826 product page.

Apparent nonlinearity

To prevent high CMV, connect isolated source to ADC ground.

Many of our customers have observed ADC nonlinearity during development and discovered that that it was caused by excessive common-mode voltage (CMV). This often happens when the ADC is used to measure an isolated voltage source such as a battery, thermocouple, or isolated power supply. Since the source is isolated, the CMV may float up or down until it exceeds the maximum allowed CMV of the ADC's input circuitry.

If you are using an isolated source, be sure to connect one side of the source to the ADC power supply ground as shown in the diagram to the right. This will prevent high CMV that might othewise result in apparent non-linearity or calibration errors.

Counters

Snapshot counts upon match

When a snapshot is caused by counts equal to a compare register, the snapshot counts will always be equal to the compare register value.

Programming for incremental encoders

Which functions should I use for incremental encoders?

There are many options, but basic operation works as follows:

First configure and enable the counter channel:

Call S826_CounterModeWrite() with mode=0x00000070
Call S826_CounterStateWrite() with state=1

To read the current encoder counts:

Call S826_CounterRead()

DIOs

Generating a burst of pulses

How can I make a DIO channel go active for 10ms and then inactive for another 10ms, and repeat this five times?

There are many ways to do this but the methods you can use depend on a number of factors. Here are two general strategies:

1. If high precision is not needed you can call S826_DioOutputWrite() multiple times, with 10ms software delays between the calls. The precision of this method depends on your operating system and system load. The code for this method is simple and straightforward.

2. If you need precise timing then you could use two counter channels. For example, using counter channels 0 and 1:

  • Counter 0: Configure as PWM generator with 10ms on/off times, with external enable. Connect its enable input to counter 1's output. The goal here is for counter 0 to enable counter 1 to output pulses; counter 0 will enable the PWM generator until 5 pulses have been generated.
  • Counter 1: Configure as event down-counter, with preload (value=5) upon enable, with external clock, with output active when counts not zero. Connect its clock input (must be external connection) to counter 0's output. The goal here is for counter 1 to count PWM pulses until it counts from 5 down to 0; it will then set its output low, thus disabling the PWM generator.
Personal tools
Namespaces

Variants
Actions
Toolbox