element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Serial Config help.
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 31 replies
  • Subscribers 405 subscribers
  • Views 3502 views
  • Users 0 members are here
Related

Serial Config help.

YT2095
YT2095 over 13 years ago

I need to configure the Serial on an Arduino to match a very strange Printer, I`m not even sure it`s possible with an Arduino?

it needs to be:

 

1200 Baud

1 Start bit

7 Data bits (LSB first)

1 Parity Bit (Even)

and 2 Stop Bits.

 

Does anyone know how config for this in Arduino, or even if it`s possible?

 

Thanks image

  • Sign in to reply
  • Cancel

Top Replies

  • R_Phoenix
    R_Phoenix over 13 years ago in reply to billabott +1
    SoftwareSerial is no different than useing the built in Serial port. I don't know of anything that even still uses the start bit. As far as I know, the serial port on an Arduino is only 3 wires, RX, TX…
Parents
  • SGarciaV
    0 SGarciaV over 13 years ago

    Perhaps this thread will help:

     

    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1243894373

     

    Good luck! Salvador

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to SGarciaV

    I`d looked at that earlier today, and the parts I could make sense of don`t address the Start Bit issue, that`s why I was even wondering if it was possible?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    Have you written some experimental code and wired it up yet?

    What was the printer originally designed to connect to? 

    Can we assume the serial port on a PC?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to billabott

    it`s a PXP40 that goes on a PX1000 Telex machine, the connector is like a stereo earphone jack, no PC involvment per se.

    as for test "code" I`v tried 3 different terminal progs, and non of them work as there`s no config for a start bit image

    the printer Does work however as I tried it on the PX1000.

     

    see here: http://www.cryptomuseum.com/crypto/philips/px1000/index.htm

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    Have you looked at this page about RS-232 Serial or this page?

     

    The PXP-40 Printer is similar to the Atari 800 40 Column Thermal Printer (early 1980s)  that I own.

     

    Some systems use:  (image)

    • base ring: ground (pin 5 of DB9)
    • middle ring: serial output from Device1 to serial input of Device2 (pin 2 of DB9)
    • tip of pin: serial output of Device2 to serial input of Device1 (pin 3 of DB9)

     

    Have you been able to determine if it uses standard ASCII?

     

    Adding a start bit should not be too difficult. 

     

    You need to heed the warning about connecting 12 volt device to the i/o of the 5 volt arduino when using RS-232RS-232.

     

    Soon you will be happily running this program on your repurposed thermal printer.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    Have you looked at this page about RS-232 Serial or this page?

     

    The PXP-40 Printer is similar to the Atari 800 40 Column Thermal Printer (early 1980s)  that I own.

     

    Some systems use:  (image)

    • base ring: ground (pin 5 of DB9)
    • middle ring: serial output from Device1 to serial input of Device2 (pin 2 of DB9)
    • tip of pin: serial output of Device2 to serial input of Device1 (pin 3 of DB9)

     

    Have you been able to determine if it uses standard ASCII?

     

    Adding a start bit should not be too difficult. 

     

    You need to heed the warning about connecting 12 volt device to the i/o of the 5 volt arduino when using RS-232RS-232.

     

    Soon you will be happily running this program on your repurposed thermal printer.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • YT2095
    0 YT2095 over 13 years ago in reply to billabott

    the 12v/5v thing isn`t an issue, I`v dealt with all that stuff before and simply use a cmos inverter, I`ll not be tapping the power anyway, just the GND and the Data (sleeve and tip), and the data is +/-5v capped.

    I fully understand What it wants, I`v just no idea how to make an Arduino do it, and don`t really want to mess around building Parallel to Serial convertor out of 74xx series chips, and messing around with clock divisions for framing etc...

    Happily the one "Normal" part about this is that it IS ASCII code, but that`s about where it ends.

     

    it`s a nice little printer and I managed to save it`s life and change out the batteries before too much damage was done, and I think it would make a great addition to ZED.

     

    the goal is have 8n1 serial IN and this crazy protocol come OUT of the arduino (same baud naturally), to drive it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    All right then, YT2095, my research on arduino.cc indicates that

    #include "SoftwareSerial.h" would be a good beginning.

     

     

    /*
       Software serial multple serial test
     
      Receives from the hardware serial, sends to software serial.
      Receives from software serial, sends to hardware serial.
     
      The circuit:
      * RX is digital pin 2 (connect to TX of other device)
      * TX is digital pin 3 (connect to RX of other device)
     
      created back in the mists of time
      by Tom Igoe
      based on Mikal Hart's example
      modified by Wm. A. T. Bottger, 01 May 2012
     
      This example code is in the public domain.
     
      */

    #include <SoftwareSerial.h>

    SoftwareSerial mySerial(2,3); // RX, TX   i/o pins on Uno

    void setup() 
    {
       Serial.begin(19200);
       Serial.println("Enter text to be printed:");  
       // Displayed on Serial Monitor
       // using Digital pins  1

       // set the data rate for the SoftwareSerial port
       mySerial.begin(1200);
       //  Will be updating this shortly  -WATB
       //   While you are waiting, why not try it out as it is?
       //mySerial.println("Arduino Uno sending text:");
       // Output onto device connected to UART
       // using digital pin 3
    }

    void loop() // run over and over
    {
       if (mySerial.available())
         Serial.write(mySerial.read());
       if (Serial.available())
         mySerial.write(Serial.read()|0x80);
    }

     


     

    If you are using Arduino 1.0 then  this include is already part of 1.0

    and the following are available:

    Functions

    • SoftwareSerial()
    • available()
    • begin()
    • isListening()
    • overflow()
    • peek()
    • read()
    • print()
    • println()
    • listen()
    • write()
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 13 years ago in reply to billabott

    SoftwareSerial is no different than useing the built in Serial port. I don't know of anything that even still uses the start bit. As far as I know, the serial port on an Arduino is only 3 wires, RX, TX, and Ground. So you won't be able to configure the flow control.

     

    However I would sugest asking this on the Arduino Forums. if you haven't already.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to billabott

    agreed, I use this library on a few things, one of which is a printer ironically image

    I use the NewSoftSerial library, more or less the same as the above anyway, only I can`t see anywhere to config it with a Start bit and 7E2?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    Have you tried casting the variable as a double?

    Here is my idea:

    Given an AsciiChar Byte which Serial.read() has provided from the Console:

    NewChar = AsciiChar|0x80;  // set the first bit high so you have the "Start Bit"

    DoubleChar = (NewChar * 4) + 3;  // shift the bit pattern left 2 positions and

    // set the two low order bits high for the "Stop bits"

     

    If softwareserial cannot handle the double, then break it into two bytes

    and send them one after the other using myserial.write.

     

    // On the other hand it seems that

    myserial.print(NewChar + 0xc0);  // might get the job done too.

    // this +  is a string concatination. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to billabott

    I`ll give both of those ideas a shot tomorrow image

    just out of curiosity however, does anyone know what Endian the arduino sends it`s serial data?

    another quirk of this printer is that it has to be little endian to work  *sigh*

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billabott
    0 billabott over 13 years ago in reply to YT2095

    Additional info:

     

    We cannot trust what we see on the Serial Monitor.  (reference here)

     

    Instead of the last line in the code above; I recommend trying the following:

     

    mySerial.write(((double(Serial.read()| 0x80)) *4)+3);

    or

    mySerial.write((((double(Serial.read()| 0x80)) *4)+3)* 0x0010);

     

    A really complete ASCII chart can be found here.

     

    Okay, I don't know if this will work for you or not; it is just my theory.

     

    If it does not work out then feel free to say so after

    reporting your Serial Monitor test inputs and outputs from the PXP-40.

    A screen capture and a clear photo of the thermal paper would be ideal.

     

    Always remember to "Stay Calm and Carry On."

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to billabott

    ok, here`s what I have so far:

     

    #include <NewSoftSerial.h>

     

    NewSoftSerial Thermal(2,3); // RX TX. only TX used

     

    void setup()

    {

       Serial.begin(9600);

       Serial.println("Enter text to be printed:"); 

     

       // set the data rate for the SoftwareSerial port

       Thermal.begin(1200);

        // UCSR0C = B00100100; <--doesn`t change anything?

    }

     

    void loop()

    {

       if (Thermal.available())

         Serial.write(Thermal.read());

       if (Serial.available())

       // Thermal.write((((double(Serial.read()| 0x80)) *4)+3)* 0x0010); <--won`t compile

       // Thermal.write(((double(Serial.read()|0x80))*4)+3); <--won`t compile

         Thermal.print(Serial.read()|0x80);

    }

     

    using the above, I get "393636" printed as a result of typing in "hello world".

     

    using the line(s):

    mySerial.write(((double(Serial.read()| 0x80)) *4)+3);

    or

    mySerial.write((((double(Serial.read()| 0x80)) *4)+3)* 0x0010);

     

    I get:

    /newsoftserial.h71: error: 'virtual void

    newsoftserial::write(uint8_t)' is private

    _7e2test:20: error: within this context

     

    so really I have no way to test if this will work or not?

     

     

    I`ll keep going though image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 13 years ago in reply to YT2095

    If your IDE is version 1.0, don't include NewSoftwareSerial. It is already in the IDE. so just include SoftwareSerial.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to R_Phoenix

    I use version 22 for almost everything, version one only really gets used if I program an ATtiny85.

    22 has all my collection of libs and hardware tweeks, I`m of the mind that if it aint broken, don`t fix it, so I stick with 22.

     

    anyway, my lunch break is over, so I`m trying with Thermal.Print instead of Write, it will at least compile then.

     

    results later image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube