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
    About the element14 Community
  • 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 420 subscribers
  • Views 4969 views
  • Users 0 members are here
Related

Serial Config help.

YT2095
YT2095 over 14 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 14 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…
  • billabott
    0 billabott over 14 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 14 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 14 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 14 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 14 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 14 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
  • billabott
    0 billabott over 14 years ago in reply to YT2095

    That is curious. I compiled those lines on Arduino 0023 and the platform is Duemillanova with no complaints.  Very curious indeed.

    here is what I am using:

       if (Serial.available())

       {  

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

        // I am pretty sure the 0x0010 can be replaced with 8

         Serial.println (kount++);

       }

     

    Most of the time it returns a weird "p"  but each character output is on a new line with a number next to it.

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

    Well, the time has come to step into the future with Arduino 1.0.

     

    The thermal printer solution is here.  It uses a 'Modern' Thermal Printer.

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

    this is what I`m using currently that will compile:

     

    #include <NewSoftSerial.h>

     

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

     

    void setup()

    {

      Serial.begin(9600);

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

       Thermal.begin(1200);

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

    }

     

    void loop()

    {

       if (Serial.available())

        //Thermal.print((((double(Serial.read()| 0x80)) *4)+3)* 0x0010);

        Thermal.print(((double(Serial.read()|0x80))*4)+3);

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

    }

     

    the results I get for the line "Thermal.print(((double(Serial.read()|0x80))*4)+3);" after typing in "hello world" are:

    93.0099.009.009.009.0095.00555.0

     

    for the line "Thermal.print((((double(Serial.read()| 0x80)) *4)+3)* 0x0010)" again with "hello world", i get:

    96.00theta0.0055.00theta5536.0055.0060.000.0

     

    and plain old "Thermal.print(Serial.read()|0x80);" gives me:

    393636  again with "hello world"

     

    I`m getting a LOT of banding now as well, old paper maybe?

     

    as for the other thermal printer, I already have one of those that I use occasionally with my Seimens TC35 GSM module image

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

    My last suggestion is to put

    Thermal.print(kount++);

    inside the Loop()

    just to see if you ever get anything intelligible.

     

    and if you really want to push it make kount type double.

    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube