@ke5awf There was no link to a VJ11 on the Gurley website. Can you provide a link to the data sheet of the encoder you are trying to read?
As Tom George says, if the output format is SSI then you can clock and read it directly with the Arduino.
I am using a TI SN75178BP to convert CLOCK+ CLOCK- to D and DATA+ DATA- to R.
I'm not familiar with this interface, but your code looks wrong for SSI. Typically, using the clock pulse/read in the "for loop", you would read the data into an array, (or use bit shifting to compose the 25 bit data stream into a long value) before doing the extractions.
The bracketing arrangement in you code has you reading a bit into dataValue, performing some bit extractions, and bit shifting dataValue>>4 all before the complete data has been read into dataValue.
cattledog: @ke5awf There was no link to a VJ11 on the Gurley website. Can you provide a link to the data sheet of the encoder you are trying to read?
As Tom George says, if the output format is SSI then you can clock and read it directly with the Arduino.
I'm not familiar with this interface, but your code looks wrong for SSI. Typically, using the clock pulse/read in the "for loop", you would read the data into an array, (or use bit shifting to compose the 25 bit data stream into a long value) before doing the extractions.
The bracketing arrangement in you code has you reading a bit into dataValue, performing some bit extractions, and bit shifting dataValue>>4 all before the complete data has been read into dataValue.
I can't seem to find another copy of the manual online, other than the one that was emailed to me.
clock is over RS422
DATA is over RS422
I am using the TI chip to make CLOCK+ CLOCK- to just CLOCK and DATA+ DATA- to just DATA
Hi
Refer post #2, did you try the sketch I refered to?
Or at least looked at how it works, it is very well commented.
Are you using 120R resitors across the pairs?
Tom...
TomGeorge:
Hi
Refer post #2, did you try the sketch I refered to?
Or at least looked at how it works, it is very well commented.
Are you using 120R resitors across the pairs?
Tom...
I did try your code you linked, it does not work, looking at the scope, I think I am possible running into timing issues on the Arduino and that it might not be a viable platform for this unit.
If I am understanding the documentation correctly, I have to pulse the unit 25 times in 15Microseconds at max. with each pulse being at least 120NanoSeconds.
If I am understanding the documentation correctly, I have to pulse the unit 25 times in 15Microseconds at max. with each pulse being at least 120NanoSeconds.
No each clock pulse has to be completed within 15 us, and the minimum H or L time is 120 ns. digitalRead() and digitalWrite() are about 3-4 us each, and time out well with SSI.
Your port manipulation and delayMicroseconds(3) should be equivalent and should work as the clock pulse.
Ok I have it getting data back now... someone unplugged my Negative lead, I didn't see it till today.
I used the code in the other page linked, and then modified it.
const int CLOCK_PIN = 5; //CLOCK to RS422 CHIP
const int DATA_PIN = 6; //DATA from RS422 CHIP
const int BIT_COUNT = 25; //BITS needed to be read from encoder
static unsigned long int outputValue = 0;
void setup() {
pinMode(DATA_PIN, INPUT);
pinMode(CLOCK_PIN, OUTPUT);
digitalWrite(CLOCK_PIN, HIGH);
Serial.begin(115200);
}
void loop() {
long int reading = readPosition();
// outputValue = reading >> 0;
Serial.println(reading);
delay(200);
}
//read the current angular position
float readPosition() {
unsigned long sample1 = shiftIn(DATA_PIN, CLOCK_PIN, BIT_COUNT);
delayMicroseconds(30); // Clock must be high for 20 microseconds before a new sample can be taken
return sample1;
}
//read in a byte of data from the digital input of the board.
unsigned long shiftIn(const int data_pin, const int clock_pin, const int bit_count) {
unsigned long data = 0;
for (int i=0; i<BIT_COUNT; i++) {
data <<= 1; // shift all read data left one bit.
//digitalWrite(clock_pin,LOW);
PORTD &= ~(1 << 5); // clock pin goes low
delayMicroseconds(1);
data |= digitalRead(DATA_PIN);
//digitalWrite(clock_pin,HIGH);
PORTD |= (1 << 5); // lock pin goes high
delayMicroseconds(1);
//data |= digitalRead(DATA_PIN); // cat the new read bit to the whole read data.
}
return data;
}
The only problem now is I cannot get a 0 result to come back from this encoder.
It should be 19Bit(524,288)
If I drop the BIT_COUNT to 19 I get numbers in the range I expect but I get to 524,288 and the next thing that shows up is its half and it starts all over again.
Am I reading the data wrong somewhere? Am I missing a sign bit?
If I put the BIT_COUNT to 25, I get numbers like 16756079
Ok, so as long as I have the oscilloscope attached it is consistent on these values. However as soon as I take the oscilloscope out, I am getting values changing randomly, could this be due to a ground loop?
I am grounding the oscilloscope lead to the bread board and then looking at port 2 which is the R port on the RS422 chip.
I am reading it MSBFIRST, I will upload the VJ11 Manual and send it as a link, they no longer have it on their site.
If I am reading the oscilloscope correctly, its a stuck bit from the encoder, which doesn't make sense to me. It may be possible I need to introduce a 1K resister on the read line, but for how short the link is, I did not think I would need it.