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.

Sensors, Actuators, and Robotics » Using PuTTY to see outgoing data

June 26, 2012
by mcgroover
mcgroover's Avatar

Hi all,

I have used PuTTY to detect incoming data from the microcontroller to the computer, but I haven't yet found a way to see what is being sent to my microcontroller from my computer. When I am running a python program to communicate with the microcontroller, PuTTY will tell me that the port is in use.

Does anyone know how to get around this and see what is being sent to the microcontroller?

I have tried to display incoming data on my LCD but I am having the 1st and 3rd line issue with squares even after rewiring... :(

Thanks.

June 27, 2012
by Ralphxyz
Ralphxyz's Avatar

Load the Initialload program does that work?

Ralph

June 27, 2012
by mcgroover
mcgroover's Avatar

Hi Ralph,

Nope, initialload does not work. I have not stripped the breadboard completely though (only the LCD wires), so will probably do that tonight. It is strange because the microcontroller is functioning properly apart from this. I will post pictures of the setup if it doesn't work after tonight's open heart surgery. I may just buy a new LCD too as they are not too expensive.

Do you agree though that the LCD is probably the only way to see what it coming in to the microcontroller?

Thanks!

Chris.

June 27, 2012
by Ralphxyz
Ralphxyz's Avatar

Well you can/first should check the echo I think you connect the yellow and green wire together.

With that you should see in putty what you are sending out echoed back.

Better details on setting up the echo is in the ... Nerdkits tutorial.

Sorry I forgot which tutorial has the instructions.

When I am having problems I always revert back to initialload to get a handle on where my problem lies.

Strip the breadboard down and start over it really does not take that long after two or three tries.

Also it is good to have additional (hopefully working) breadboards so when one acts up (which they do) you can just switch and continue your project and trouble shoot later on.

Ralph

June 27, 2012
by mcgroover
mcgroover's Avatar

Sigh, no luck with the stripping of the breadboard and rewiring. I will just buy another kit as I need a second one anyway.

I saw Humberto's suggestion about the echo back, but it seems that PuTTY will need to send the instructions to echo back. I would like to see if the python program is sending the data and in this case I think python is hogging the port (and PuTTY can't connect to it).

Anyway, I will see how I go with the second system.

Thanks for the help!

June 28, 2012
by Rick_S
Rick_S's Avatar

As far as I know, only one program can access the serial port at a time. So if Python has it opened, Putty cannot open it and vice versa. I don't know of any software way to monitor serial data on the same computer. Serial sniffers monitor traffic, but they are hardware devices that connect to the serial lines themselves.

Rick

June 30, 2012
by photofoo
photofoo's Avatar

I found a very handy app to deal with serial communication. It allows me to watch both sides of the conversation between the nk and my pc. This is working well on my PC with windows XP. Here is the link good luck http://www.serial-port-monitor.com/index.html

July 02, 2012
by mcgroover
mcgroover's Avatar

Got the new LCD and it worked! (not sure how I damaged the first one).

Photofoo, sounds like a great program. I tried to install it on my computer and it seemed very picky about the user rights and I can't get it to run (I will try later on another computer with more rights, though).

Now that I have my new LCD and it can show what the microcontroller, I have a strange output. My microcontroller code is:

define F_CPU 14745600

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include "../libnerdkits/uart.h"

int main() {

  uart_init();
  FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
  stdin = stdout = &uart_stream;
  int32_t temp = 20;
  int32_t output = 0;

  lcd_init();
  FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putchar, 0, _FDEV_SETUP_WRITE);
  lcd_home();

  while(1) {
  lcd_home();
  printf_P(PSTR("%d\r\n"), temp);   
  fprintf_P(&lcd_stream, PSTR("Output is %3ld"), output); //write message to screen
  output = uart_read();

}
  return 0;
}

My python code is

import os, pygame, math, serial   
from pygame.locals import *
from pygame.compat import geterror
from time import clock, time
pygame.init()
w = 1100   #sets pygame screen width
h = 642   #sets pygame screen height
screen = pygame.display.set_mode((w, h),0,32)  #make and display screen

pygame.display.flip()   #Update screen
running = 1
font = pygame.font.Font(None, 36)
clock = pygame.time.Clock()
port = serial.Serial("COM2", 115200)

while running:          #Loop this
   for event in pygame.event.get():    #get user input
      if event.type == pygame.QUIT:    #if user clicks the close X
           running = 0                 #make running 0 to break out of loop

   port.write('30')
   temp = float(port.readline())
   clock.tick(100)
   value = font.render(str(temp), 1, (100, 100, 100))
   screen.blit(value, (280,165))
   pygame.display.flip()   #Update screen

The microcontroller always outputs 48 on the LCD screen? Anyone have an idea why? Does it have something to do with value type conversion?

July 02, 2012
by mcgroover
mcgroover's Avatar

Now it is switching quickly betwee 48 and 51?

Post a Reply

Please log in to post a reply.

Did you know that signed numbers need to be sign-extended when chaging variable sizes? Learn more...