Hi,
I’m working on a simple thermoscan project. I’m using Devantech’s TPA81 thermal array sensor and two servos to scan an area for temperature changes.
Then all the data are sent through serial communication to a Picaso uVGA-II processor that “prints” an image
in any screen that has VGA output creating a “thermal” image.
The Picaso can be accessed through a simple serial TTL port.
Anyway, the first part was easy, using a FEZ Panda and two servos I get all the data through I2C.
The issue I have is with the Picaso. It accepts simple byte commands in two ways: either by sending a Hex
number or a character representing the command you want to use.
For example, by serially sending 0x55 or ‘U’ , you send the Autobaud command.
The problem lies in the code I use, by having C# understand what exactly I want to send.
I have made a small class to have all the commands in one place. I have debbuged The “Send” or “SendChar” function I use, and it seems to send the correct data, but nothing happens.
I have tried any available code I found on the Internet but it seems that the command is sent in the wrong way and also I can’t seem to read anything back ( like an ACK or NAK response sent by Picaso).
Below, you can see a part of the code I am using,
P.S. I also use the Picaso with an Arduino Mega using the same logic in my code and it works perfect!
What is that I make wrong in this code??
Thanks!
using System;
using System.IO;
using System.Text;
using System.IO.Ports;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
namespace VGAClass
{
public class Picaso
{
private static SerialPort UART;
private byte Screen_res = 0;
private byte Picaso_ACK = 0x06; //command received-acknowledged-executed
private byte Picaso_NAK = 0X15; //command not recognized
public Picaso(string Comport, int baudrate)
{
UART = new SerialPort(Comport, baudrate);
UART.BaudRate = 9600; //9600 default rate for Picaso intialization
UART.DataBits = 8;
UART.Parity = Parity.None;
UART.ReadTimeout = 0;
UART.WriteTimeout = 0;
UART.Handshake = Handshake.None;
UART.Open();
}
public void Send(byte data) //send a command byte
{
byte[] buffer = new byte[data];
UART.Write(buffer, 0, buffer.Length);
}
public void SendChar(char data) //send a char-like command
{
byte[] buff = new byte[data];
UART.Write(buff, 0, buff.Length);
}