I'm attempting to use an Arduino Uno and a potentiometer to control a Bijou 600 amplifier via RS232. I have a MAX3232 to convert Arduino's TTL to the amp's RS232 input, and I'm fairly confident my wiring is correct.
My current assumption is that my code is not sending the carriage return line that the amplifier expects. From the amp's automation guide:
Simple ASCII is used to issue command strings via RS232. Carriage return (0x0D) / is required to end the transmission of the command string i.e. To turn on the AccuBass, simply send bass1
Bijou volume is from 0 to 63, so to set the volume at max the bijou expects to see setvol63
If the Bijou doesn't like the code you're sending it should send back the same code you sent it with an asterisk, but I haven't figured out how to read ASCII off the receive pin.
The code includes LEDs that turn on and off in sequence with the level of the potentiometer, that works fine.
byte led_pins[10] = { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2 }; // easier to wire in reversed order
#include <SoftwareSerial.h> // allows additional pins to act as Rx and Tx for serial commands
#define rxPin 12
#define txPin 13
SoftwareSerial mySerial(rxPin, txPin);
// Set up a new SoftwareSerial object
int pot_value = 0; // potentiometer value
int newVol = 0; // old volume value
void setup() {
for (int i = 0; i < 10; i++) {
pinMode(led_pins[i], OUTPUT); // initialize digital pins as outputs (in order to control LEDs)
}
pinMode(A0, INPUT); // set A0 as input for reading the potentiometer value
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(19200); // Baud rate of the Bijou 600 is 19200
Serial.begin(19200);
}
void loop() {
pot_value = analogRead(A0); // read the value of the potentiometer
pot_value = map(pot_value, 0, 1023, 0, 63); // map the value between 0-63, as this is the range used on the Bijou
if (pot_value != newVol) {
newVol = pot_value;
mySerial.print("setvol"); // RS232 volume command for the Bijou 600 is setvolx, where x is a number between 0 and 63
mySerial.print(newVol);
mySerial.println(); // This combination of print+printline should send the setvol'x' command to the Bijou's RX pin.
// according to documentation myserial.println() includes a carriage return so it should work. adding '<cr>' or '\r' did not help.
Serial.print("setvol");
//Serial.print(newVol);
Serial.println(newVol); //allows me to see the code going to the bijou in the Arduino Serial Monitor
Serial.print("A0 is ");
Serial.print(analogRead(A0)); // so I can know potentiometer value
Serial.println();
}
// light up the corresponding LEDs
for (int i = 0; i < 10; i++) { // set the LEDs based on the potentiometer value
if (pot_value <= i * 6.3) {
digitalWrite(led_pins[i], LOW); // LED off
} else {
digitalWrite(led_pins[i], HIGH); // LED on
}
}
}