Good day, RobotShop community.
Some months ago I got a Rover A4WD1 w/Encoders from here:
robotshop.com/en/lynxmotion- … oders.html
Alongside a Phidgets SBC3 (Minimal Debian OS) and a SSC-32 v2 (Serial).
I managed to get the DC motors of the Rover working just fine with the Serial communication through the SSC-32.
However, the problem comes when trying to read any kind of input (Digital or Analog) from the ABCD ports of the SSC-32 v2.
I am trying to get a signal which is supposed to be a binary character (ASCII) of either 0 or 1 depending on the value of the encoder of the Rover.
(Here’s a page of the encoder for reference: robotshop.com/en/lynxmotion- … coder.html)
The encoder seems to have a Yellow and Green cable for Output A and B.
I connected an oscilloscope into them and got an square signal as follows:
[size=4]Output A (Green cable) connected only.[/size]
[size=4]Output A and B connected both to the oscilloscope [/size]
Given the output signal I got in the oscilloscope, I am assuming this has to be a digital input.
According to the User Guide of the SSC-32 v2, the digital inputs can be read by sending ABCD into the SSC-32.
However, I seem to fail to get any kind of response out of it.
Here’s the code that I’m using to try to get it to work through serial connection connect to the Phidgets SBC3 (/dev/ttyUSB0) to the SSC-32 v2:
[code]#include
#include
#include <stdio.h>
#include <fcntl.h> /* For O_RDWR */
#include <unistd.h>
#include
#include <termios.h>
#include
#include <stdlib.h>
#define SERVO_DELAY 1000
#define Q_DELAY 10
#define RAD 57.29577951
//#define m 0.1664292499
#define md 9.535693606
#define PORT “/dev/ttyUSB0”
#define CHANNEL_NUM 10
#define STD_SPEED 250
#define BAUD_RATE " 9600"
#define PI 3.141592654
#define DELAY_ARM 20000
using namespace std;
#define phi0 0
double pos,vel;
int can;
//g++ -o input input.cpp
int main(int argc, char *argv])
{
int usbdev;
int i;
ofstream fw;
char cData[1];
unsigned char uData;
fw.open(PORT);
system(“stty -F” PORT BAUD_RATE);
usbdev = open(PORT, O_RDWR| O_NONBLOCK, S_IRUSR | S_IWUSR);
KServo p0(95,20,0); // This simply starts the DC motor at a low speed to get a signal from the encoder.
for(i=0;i=1000;i++){
fw << “A B C D” << “\r” << endl;
read(usbdev, cData, 1);
uData = cData[0];
cout << uData << " ";
}
close(usbdev);
fw.close();
}
[/code]
The part where I am trying to read from the ABCD ports is located inside the ‘for’ cycle.
Could someone help me out to figure out what is going on and why I cannot get any kind of response?
Any kind of help would be greatly appreciated.
Thanks in advance!
**PS: **The serial connection is working since I am able to control the DC motors just fine with a similar kind of code, just applying the #P, etc variants for them from the SSC-32 User Guide.