Maxserial and WRT54gl

Hello Everyone,

For my project I am trying to connect a WRt5gl router to my maxserial controller but when I connect them nothing happens, I cant tell if a signal is being sent. I am using thecode that John wrote on jbrojects the link is here: http://jbprojects.net/projects/wifirobot/car_arduino.c Can anyone tell me how to test so see if the router is sending anything to the controller? Also I am using a rs232c serial cable and on the routers serial port tx is pin 3 and rx is pin 2. Please let me know if you need more info.

Also if you want to understand exactly what I am triyng you can find the full project here:http://jbprojects.net/projects/wifirobot/

More info. How did you go about adding the serial port to the WRT54? It doesn't come with RSR232 level converters from the factory, just 3.3V TTL level which won't be happy with arduino levels and it won't be inverted.

Did you test it with a PC first? You can add activity LED's if you are using a MAX232 circuit that has room to add them.

Testing the ports should be easy Hook it to a computer running a serial terminal and set it to 9600,N,8,1. Type a few characters and press enter... you should get it echoed back.

You should be sure of that before testing Arduino serial... but you didn't mention it... so that's why I'm asking/commenting.

Thanks you make a very good point. I used the serial port from curious inventor the link is here: http://www.curiousinventor.com/kits/spk_wrt

To test the router I connected it to my serial port and turned on serial port monitor. I then typed echo "hell" >/dev/tts/1 I didnt however set the port speed. What would the syntax for that be?

The router will spit out console messages when it boots. Do you get those?

Maybe I had the speed wrong. Set your serial port config to 115200, 8 bits, no parity, 1 stop bit (8N1), reboot your router... it will spit boot messages at you.

You have LINUX on it already, right?

I tried turing on the serail moitor and I connected the router to the pc and rebooted the router. There was nothing seding over. Also would the router send over tts1 on reboot when tts0 is the default?

TTY0 is the console. It provides kernel messages during boot up and behaves as the default console. TTY1 is not pre-configured.

I just changed the Braud rate to 115200 and i tuned on the serial monitor that is built into the arduino enviorment and i sent the eco comand and it is working. The serial moitor I downloaded however dosent see what I send, dont know why. So since the router is sending data I guess the problem is on the arduino side. I was told on jbprojects that when the rotuer talks to the microcontroller it causes the controller to reset. I followed the steps online to connect a resistor between the reset and 5v. Does that work or is there a better way to turn off the auto reset?

Autoreset shouldn't be an issue if you are only connected to the router as it only uses RX, TX, and gnd. The autoreset is tied to the cts or rts line. If you have the Arduino connected to your computer, it will reset when you open and close the serial monitor. Which brings me to my question. How exactly to you have this hooked up and what model Arduino are you using? If you are using the serial Arduino pictured in the project, how do you have your computer connected?

Im using a radioshack serial cable that is straight through. I connected the router to the a maxserial. So the only way I can tell if the arduino is doing something is if the led flashes. Also when it receives the right character the voltage of digital pin should rise. Also this is the board Im using. http://store.fundamentallogic.com/ecom/index.php?main_page=index&cPath=3

Also this is what the website said about the auto reset but I dont have a 10k pull up resistor and there is no store around here with them.

The Freeduino MaxSerial uses serial pin 4 - DTR (data terminal ready) to reset the microcontroller and allow it to download new code. Under normal PC operation this pin is either +10V or -10V depending on whether the serial port is connected or not. However, this pin is grounded on the router serial port and isn't active. When the router serial port starts sending data, the MaxSerial resets. That's no good for us. We are going to pull-up the DTR pin to +9V. With this quick hardware modification, it basically adds a program-locked mode so that new code can't be uploaded and the microcontroller can't be reset by the serial port. If you need to reprogram it, just flip the switch. +9V is a pin with easy access on the Freeduino MaxSerial.

Yes, my mistake, it is the DTR line. But like I said, this line is not connected in your situation so I wouldn’t think it would cause the Arduino to reset. However, I don’t have the maxserial verify that with. If that truly is the problem, you could simply remove the autoreset cap (CRS) rather than using a pullup resistor. That would force you to use the reset button for uploading though.

Do you know which cap it is to turn off the auto reset?

The one labeled CRS just below the maxserial logo in the picture.

I have the autoreset off and still no luck. So far this is what I have.

If I connect the router to my pc via the serial cable and type echo 'hi' >/dev/tts/1 I get hi back on my pc.

If I connect my controller to my pc and send it 'hi' it sets digital pin 8 to HIGH.

If I connect the router to the controller and run the echo command pin 8 stays at ground when the result should be HIGH .

Do you guys have anymore ideas? I am very thankful for all of your help.

Can you post the actual Arduino code you are using to test?

The orginal code can be found here http://www.jbprojects.net/projects/wifirobot/car_arduino.c

No matter what code I use the micro controller wont respond to the router.

But I modified it a bit like below.

#define DEBUG 0
//i turned off the wait for start.
#define WAIT_FOR_START 0

unsigned char incomingByte = 0;
unsigned long loop_count = 0;
unsigned char horn = 32;
unsigned char redLED = 64;
unsigned char greenLED = 128;

unsigned char forward = 1;
unsigned char backward = 2;
unsigned char left = 4;
unsigned char right = 8;

unsigned char PORTB_val;
unsigned char PORTD_val;

unsigned char in_char = 0;

void setup()
{
//PORTD = digital IO 0-7
//horn, redLED, greenLED

pinMode(5, OUTPUT); // sets the digital pin as output
pinMode(6, OUTPUT); // sets the digital pin as output
pinMode(7, OUTPUT); // sets the digital pin as output

//PORTB = digital IO 8 - 13
//right, left, backwards, forward

pinMode(8, OUTPUT); // sets the digital pin as output
pinMode(9, OUTPUT); // sets the digital pin as output
pinMode(10, OUTPUT); // sets the digital pin as output
pinMode(11, OUTPUT); // sets the digital pin as output

Serial.begin(9600); // set up Serial library at 9600 bps

PORTD = redLED; // turn on the red LED

#if DEBUG
flash_led(3,500);
#endif

wait_for_start(); //Waits for startup message from router serial port
//continues after receiving it.
}

void flash_led(unsigned int count, unsigned int rate)
{
// debug routine that flashes an LED

int n_count = 0;

while (n_count < count)
{
n_count++;
digitalWrite(13, HIGH); // sets the LED on
delay(rate); // waits for a bit
digitalWrite(13, LOW); // sets the LED off
delay(rate); // waits for a bit
}
}

char get_char()
{
//Function that waits for a character from the serial port
//If none are received, it returns 0.
//The timeout is so that if the router stops sending data to the microcontroller,
//the micrcontroller will stop driving the car, rather than just going forever with
//the last command. Timeout is around 250mS.

while (loop_count < 30000)
{
loop_count++;

if (Serial.available() > 0)
{
incomingByte = Serial.read();

//this is the line i added, it works if I hook the controller to the pc and type h in the serial monitor.
if(incomingByte== ‘hi’)
{
digitalWrite(13, HIGH);
digitalWrite(8, HIGH);
}
loop_count = 0;
return incomingByte;
}
}

loop_count = 0;

#if DEBUG
Serial.print(‘X’, BYTE);
#endif

return 0;
}

unsigned char wait_for_start()
{
//Waits for startup message from router serial port
#if WAIT_FOR_START

#if DEBUG
Serial.println(“Waiting…”);
#endif

while(1)
{
if (get_char() == ‘j’ && get_char() == ‘b’ && get_char() == ‘p’ && get_char() == ‘r’ && get_char() == ‘o’)
{

#if DEBUG
Serial.print(“Passcode Accepted”);
#endif

return 0;
}
}
#endif
}

void loop()
{
//Function that processes input from serial port and drives the car based
//on that input.

in_char = get_char();

//Split byte received in to upper and lower halves.
PORTB_val = in_char & 0x0F;
PORTD_val = in_char & 0xF0;

//Make sure the greenLED is turned on now.
if ((PORTD_val & greenLED) == 0)
{
PORTD_val = PORTD_val + greenLED;
}

//The following IF statements are sanity checks to make sure that FORWARD and BACKWARD cannot be on at the same time
//and that LEFT and RIGHT can’t be on at the same time.
if ((PORTB_val & (left + right)) == (left + right))
{
PORTB_val = PORTB_val - right;
}

if ((PORTB_val & (forward + backward)) == (forward + backward))
{
PORTB_val = PORTB_val - backward;
}

//Write the processed values to the ports.
PORTD = PORTD_val;
PORTB = PORTB_val;

#if DEBUG
Serial.print(PORTD, HEX);
Serial.print(PORTB, HEX);
#endif

}

Digger450, Redline and to All,

Have you guys finally got the router to communicate with the microcontroller?

I use this type of microcontroller http://mcukits.com/2009/03/12/assembling-the-freeduino-serial-v20-board-max232/ , what capacitor will I remove to stop the auto reset feature?

Your response would be of great help

Regards