NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » PuTTY don't like me...

February 13, 2010
by Herover
Herover's Avatar

Hi, I made a simple file combining the code from the Servo Squirter and blinking LED, to make a LED blink when a key is pressed - I wanted to find out how to communicate with the microcontroller.

When I open up putty.exe it shows me the window from your picture and I fill it out like you did, but then I run the program (while the microcontroller is on with the program) and just show me a black window with a green square. I can't write anything, and nothing happen when I try.

Help me!

And I use Vista.

February 13, 2010
by treymd
treymd's Avatar

quick test... put the yellow and green wire from your cable in the same row so that you get a loopback connection. Open putty and type, if everything you type shows up, then your serial port settings are correct. If not, the most likely problem is that you have selected a different COM port than the one the nerdkit is actually on.

There could be of course other bugs, but this simple test can eliminate one of them.

February 13, 2010
by Herover
Herover's Avatar

Okey, it show all I type. It did actually also type 'ba', and sometimes other kind of funny stuff, when I turned the controller off earlier (couldn't stop testing after I did this post).

Also, I guess that it's my code that's something wrong with. If I open putty before I turn it on, nothing happen. But if I turn it on meanwhile, it makes the LED light up, but now it wont stop!

In the main function it do

 DDRC |= (1<<PC4);
 // init serial port
 uart_init();
 FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
 stdin = stdout = &uart_stream;

(stolen from "led_blink.c" and the usb controlled water-thing) I'm not sure about how nice the LED part is, so here's my way of checking it with LCD in a "while(1)" loop:

lcd_home();
lcd_line_one();
lcd_write_string(tc);
lcd_line_two();
lcd_write_int16(tc);

Before pressing a button in pytty: blank. After: it write some letters, some " " and a kind of "4" letter. Line two say "||".

February 13, 2010
by Herover
Herover's Avatar

A little edit:

Line one: "|| " and a funny "4" (like in handwriting).

Line two: "48".

No difrence if i press another key.

February 13, 2010
by pbfy0
pbfy0's Avatar

is tc directly set to uart_read()? if so, then you should use lcd_write_data(tc), not lcd_write_string(tc), and to blink LED, you should be able to just do this:

while(1){
    while(!uart_char_is_waiting());
    PORTC |= (1<<PC4);
    delay_ms(50);
    PORTC &= ~(1<<PC4);
    lcd_write_data(tc);
}

for your while() loop.

February 14, 2010
by Herover
Herover's Avatar

Thanks, sure it's only my program that doesn't work as I want it.

But how should I check if it's the right button thats pressed? Right now it looks like this:

while(1){
tc=uart_read();
    while(!uart_char_is_waiting());
    if tc='b' {
        PORTC |= (1<<PC4);
        delay_ms(50);
        PORTC &= ~(1<<PC4);
        lcd_home();
        lcd_write_data(tc);
    }
}

No mater what character I press, it believe it's the right one... Something else I don't get is why even the LCD write the letter 'tc' should bee, even when I change that character or press another one.

February 14, 2010
by mcai8sh4
mcai8sh4's Avatar

guessing here, but have you tried '==' as in tc=='b'

February 14, 2010
by Herover
Herover's Avatar

Oh, it works!!!

Screen is still showing 'b' but that's not a problem right now :)

THANKS!

(and I found the "tc='b'" in the "Servo Squirter" example code, should that be fixed too?)

February 14, 2010
by Phrank916
Phrank916's Avatar

The servosquirter code I have (from the code.zip download) definitely has the == operator in the correct place. Remember that a single = is a declaration (or assignment) operator. The double == is a relational (or comparison) operator which means equal to. The single = in the line tc=uart_read(); is OK because you are declaring the variable tc to equal the return value of the uart_read function. In those other lines (the IF/THEN) you are comparing a variable with a value and checking IF it's exactly equal to that value using the == operator, THEN you doing something..

Took me a bit to get that too. :)

Ted

February 15, 2010
by Herover
Herover's Avatar

Thanks, guess I have to learn that :)

I think I also figured out why LCD only shows the character that equals true....

The stream dosen't send the correct character all the time, like it send a part of it, which is seems corect, and then it think it's the right one? Not very precise...

Post a Reply

Please log in to post a reply.

Did you know that you can connect a pushbutton to a microcontroller with only one wire? Learn more...