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 3522 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

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

    OK, I`ll do that too image

    it`ll likely not be until the weekend though, and in the meantime I`m going to throw this problem OPEN and include PIC chip solutions too.

    I use 16F877a and 18F4550, I think these could also be capable of such a task, perhaps?

     

    meanwhile, i`m going to get some welding done on MINDI, I need a break from all this software stuff!

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

    I would not know about the PICs but that brings a thought to mind about putting to use additional ICs like a serial to parallel for trouble shooting or solution implementation.  I seem to recall some chips that have the capability to generate more than 8 bits on their serial output pin.  So something with an I2c interface would be an cool option.  Of course the Arduino Uno can and does have the capability but apparently not under the control of SoftwareSerial unless our trick with using type double pays off. 

     

    Wait a second; what software resources are applied when communicating over the I2C wires? Could the I2C packet be configured so that the Univeral receiver (PXP-40) is fooled into printing the desired characters?

     

    N.B. You may want to put a little wait state in the Loop() to give that antique thermal printer enough time to figure out what to do with the bits it is getting.  It is possible that is its problem even now with the 'Hello World' string.

    • 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

    I would not know about the PICs but that brings a thought to mind about putting to use additional ICs like a serial to parallel for trouble shooting or solution implementation.  I seem to recall some chips that have the capability to generate more than 8 bits on their serial output pin.  So something with an I2c interface would be an cool option.  Of course the Arduino Uno can and does have the capability but apparently not under the control of SoftwareSerial unless our trick with using type double pays off. 

     

    Wait a second; what software resources are applied when communicating over the I2C wires? Could the I2C packet be configured so that the Univeral receiver (PXP-40) is fooled into printing the desired characters?

     

    N.B. You may want to put a little wait state in the Loop() to give that antique thermal printer enough time to figure out what to do with the bits it is getting.  It is possible that is its problem even now with the 'Hello World' string.

    • 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

    if I were to use other chips, i`d do it from scratch like I did before with a  1200CPS clock, a Binary counter to feed a 74150 and a 10 count RTS for next byte into the 150, the other code would be set with DIP switches.

    parity would be parsed with an inverter on on the LSB (as anything Higher will be an even number anyway).

     

    as for I2C I know very little to nothing about it yet, beyond a single temp sensor anyway 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