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 3506 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
  • Former Member
    0 Former Member over 13 years ago

    Wow. A lot of people have no clue how serial data works.

     

    1 start bit is pretty standard.

     

    "...don't know anything that still uses it..."

     

    rubbish. EVERYTHING uses it. An idling serial stream is sending "mark" (logic 1 -- which will be a negative voltage if RS-232RS-232 or positive if TTL). When a byte is ready to be sent, the data line is commanded to "space" (logic 0 -- positive if RS-232RS-232 or 0v if TTL). This is your start bit. When the receiver detects the logic 0 it knows to begin timing and extracting the bits.

     

    Yes, LSB first is "normal." No worries there either.

     

    Edit: Never mind extra bit I was adding to Salvador's bitstring. He has it right.

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

    Hi CookeMonster,

     

    Yeah, that "previous poster" was me! :-)

     

    I believed that UCSR0C was a byte, why do you have 9 bits? I understand that the bits that specify the word length are 3 bits, but 2 of these are in the UCSR0C and the third (MSB) is in the UCSR0B register.(bit 2). Thanks! Salvador

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

    Hi CookeMonster,

     

    Yeah, that "previous poster" was me! :-)

     

    I believed that UCSR0C was a byte, why do you have 9 bits? I understand that the bits that specify the word length are 3 bits, but 2 of these are in the UCSR0C and the third (MSB) is in the UCSR0B register.(bit 2). Thanks! Salvador

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

    Yes, it should be 8 bits. I counted 7 in your post. Let me put my reading glasses on and look closer. The "1" on the right needs to be 3 bits "in". Back in a flash...

     

    Edit. Yep. I don't know how I counted that wrong. Your string is correct. Original message edited.

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

    CM says:  (start "S", 7 data bits "x", even parity "P", 2 stop "SS")

     

    If the data line is held high all the time just to let the device know that it is connected, then okay.  I did not know that was the standard; seems a waste of electrons, IMO.

     

    If the parity bit must be present does that printer even use the parity bit?  or ignore it?

     

    So, we have

    newChar = (double((asciiChar * 8) +7)| oxf000);   //  will give  11110xxxxxxxP11

    or

    newChar = (double((asciiChar * 8) +3)| oxf000);   //  will give  11110xxxxxxxP11

    or even

    newChar = ((double((asciiChar * 8) +7) *16) + 15);   //  will give  0xxxxxxxP111111

     

    Is one of those going to work?

    • 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