Go Down

Topic: Communicating with USB w/ Uno (Read 2340 times) previous topic - next topic

justcunn

I've been trying to get my UNO to communicate with my Windows 10 device using open source code for a Braille Display device that originally worked with an Arduino device:

Code: [Select]

#ifndef SerialCommunication_h
#define SerialCommunication_h

#define Bluetooth_PIN 6

void serialEvent();
uint8_t CheckSerialCommunication();
void SetupSerial();



char inputString[StringBufferSize];         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

// set this to the hardware serial port you wish to use
#define HWSERIAL Serial1

void SerialWriteLine(String);
void SerialReadLine(char *);

void SetupSerial()
{
  Serial.begin(9600);
  //while(!Serial);
  //BT
  pinMode(Bluetooth_PIN, OUTPUT);
  digitalWrite(Bluetooth_PIN, LOW);
  Serial1.begin(9600);
  stringComplete = false;
}

uint8_t CheckSerialCommunication()
{
  SerialReadLine(inputString);
  if (stringComplete)
  {
    stringComplete = false;
    return 1;
  }
  return 0;
}

void SerialReadLine(char * buffer)
{
  uint8_t idx = 0;
  char c;

    while (Serial.available() && (idx < StringBufferSize-1))
    {
      c = Serial.read();
      if ((c == '\n')||(c =='\r')) {
        stringComplete = true;
      }
      else
      {
          buffer[idx++] = c; 
      }
     
    }
    buffer[idx] = 0;
}

void SerialWriteLine(String line)
{
    delay(10);
    Serial.println(line);
    delay(10);
    Serial1.println(line);
 
}

void SerialWriteLog(String line)
{
   delay(10);
   Serial.println(line);
   delay(10);
   Serial1.println(line);
 
}

#endif


Unfortunately I'm not with my device but I got an error basically saying that 'Serial1' was never declared. I think it could be a placeholder but I'm not too sure. Do I need to change that to my exact USB port name?

Justin

pert

#1
Dec 11, 2019, 06:40 pm Last Edit: Dec 11, 2019, 06:40 pm by pert
Serial1 is the name of the second hardware serial port. But your Uno only has one hardware serial port, Serial, thus the error. You could use Serial instead, but that port is used for communication with your computer, which includes Serial Monitor and uploads. Connecting anything to the Serial pins (0 and 1) can cause you to no longer be able to upload sketches to your Uno. Serial is also already being used in your sketch, so that is unlikely to be an option.

The alternative is to use the SoftwareSerial library to create a serial port on any pins of your Uno:
https://www.arduino.cc/en/Reference/SoftwareSerial

justcunn

Ok, that mightn't be a problem since one of the hardware ports are used for keyboards which I won't be using in my project. Could I just remove the Serial1 parts of the code (and obviously in other files where it is referenced) and move on?

pert

I haven't looked closely at the sketch, but if you're not using Serial1 then you could definitely remove that code.

FYI, examples of the Arduino boards that do have Serial1 are the Mega, Leonardo, Micro, Pro Micro, MKR boards. If you were compiling for one of those boards you would not get that error.

justcunn

Thanks very much for that. I was looking this up for ages and couldn't get a straight answer anywhere! Just to clarify, is 'Serial' the two dedicated pins? Would I be able to use my USB to communicate?

ieee488

It would be actually more helpful if you linked to whatever it is your are trying to duplicate.


.

justcunn

Sorry, I thought I had done that already.

https://hackaday.io/project/26331-development-of-a-refreshable-braille-display

The Arduino he uses isn't similar to mine and could be modified so that could be a problem.

ieee488

#7
Dec 11, 2019, 09:42 pm Last Edit: Dec 11, 2019, 09:48 pm by ieee488
I can't tell where an Arduino of any kind is being used.

Poorly documented. A master thesis project.
SMH.
I still can't find a schematic.
I give up.

justcunn

I know, it is really badly documented. The reason I'm almost sure it's an Arduino is because the file extension is .ino.

If I may ask one more question, does the USB on the Uno allow for serial communication?

CrossRoads

Under "Files" there schematics and board layouts.
Looks like it uses a Teensy 28 pin board plugged onto the main board as the controller.

Quote
Microcontroller
The main controlling unit of the braille device is a microcontroller board based on a 32 bit ARM Cortex-M0+ chip. It features a processor speed of 48 MHz and implements 62KByte Flash, 8KByte RAM, 12 analogue input and output ports, hardware Serial, Serial Peripheral Interface (SPI), I2C and a total of 27 I/O pins. [20]
The Teensy LC is a development board housing the ARM Cortex-M0+ processor chip with all required communication ports and power supply. Therefore this board can be attached through header pins as the main processing unit on the mainboard of the braille display device [21]. As every single dot of the braille display requires an extra port in order to activate it, port expander chips are necessary. Therefore the MCP23017 offers 16 output ports which can be triggered through a two-wire interface via the microcontroller. The current of the outputs and inputs is limited to 25mA. Therefore combining two ports parallel are enough to drive the required motors. [22]
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

I think it is well documented, with 4 zip files containing a wealth of info, including 4 sets of Eagles files for the electronic boards, and a Thesis describing it all. Including CAD files that I don't have the right software to open.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

justcunn

I didn't even see that, thanks!
But, the more I look into this, the more I feel this is out of my reach. Custom PCB boards, detailed schematics, and I'm trying to tweak the code to work on my bare Uno. Do you think it is somewhat possible or is it something I may have to give up on?

ieee488

#12
Dec 11, 2019, 10:11 pm Last Edit: Dec 11, 2019, 10:12 pm by ieee488
I would like to see a schematic for the entire thing.
Is that too much to ask????

It seems as if one has to get the PCBs made with the files provided and go on faith that the whole thing works together. 


.

ieee488

#13
Dec 11, 2019, 10:13 pm Last Edit: Dec 11, 2019, 10:15 pm by ieee488
I didn't even see that, thanks!
But, the more I look into this, the more I feel this is out of my reach. Custom PCB boards, detailed schematics, and I'm trying to tweak the code to work on my bare Uno. Do you think it is somewhat possible or is it something I may have to give up on?
My belief is that you need to get exactly what he used and hope it works when you have all the parts made and put together.

To the average person, I can't tell what this device is supposed to do.
I know what he says it is, but I don't work in that field.
So it seems to be more for someone who is more acquainted with devices for the blind or hard of seeing.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up