You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 11th, 2018, 11:12 PM   #1
Brandon_K
Member
United States

Brandon_K is offline
 
Join Date: Mar 2016
Location: Pittsburgh, PA
Posts: 138
Morse Code?

Possibly a bit of an odd one for a PLC, but why not.

I need to display morse code messages on a indicator lamp, but I also need to be able to change them easily, so that rules out hard coded timers.

My initial thought was to have a drum instruction for each letter. I tried this in a limited test and it works, but I'm not sure what the best way to trigger a sequence of drum instructions would be. Ideally I'd be able to put the message in a string and then convert that in a way to run the drums. But I'm not sure how to best go about that.

Dots and spaces are ~92ms, dashes are ~276ms. I'm using Productivity, so I have a fair number of instructions available.

Thoughts?
  Reply With Quote
Old January 12th, 2018, 01:44 AM   #2
Geoff White
Member
Australia

Geoff White is offline
 
Join Date: Oct 2005
Location: Brisbane
Posts: 191
I like having distinctive beeps for my machines and use a fb to generate the signal.

I pass :
a integer where the bits represent the tempo
the number of bits used
and the duration of each bit

so S = 10101
O = 11011011

You can build a structure with the lookup for each letter
  Reply With Quote
Old January 12th, 2018, 04:54 AM   #3
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Duxford
Posts: 470
Wouldn't you just require a hard coded timer of 92ms?

276/92 = 3
So a dash will be 3 spaces. If you know this, you can create an array where the bit signals the logical state during that space.
Taking the letter A for example a dot, space and dash would be
101110000

The trailing zeros would have to be enough for the longest chain you would need which seems to be the 0 clocking in at 21 bits if you decide to put a trailing space there.

I'm not sure how well this translates into the PLC side, but on a microcontroller you'd create an array of 127 positions and follow the ASCII standard. This would then allow you to use text messages in strings to be transmitted by your Morse Code interface.

Looking back it seems Geoff had the same idea apart from the timing.

Last edited by cardosocea; January 12th, 2018 at 04:58 AM. Reason: Geoff had the same idea I think
  Reply With Quote
Old January 12th, 2018, 10:00 AM   #4
gclshortt
Member
Canada

gclshortt is offline
 
gclshortt's Avatar
 
Join Date: Dec 2014
Location: Cobourg
Posts: 2,229
https://en.wikipedia.org/wiki/Morse_code
Looking at Morse code the longest number is 0. This is five long dashes. The shortest is E. This is one short dash.
In the PLC, I would try to represent each character by one word. (16 Bits)
A short dash is 10 = E
A long dash is 11011011011011 = number 0
The space between the numbers and character should be set for 0000 = space
Each character is now one word in length.
You can use the FIFO instruction or indirect addressing to point to the location for the next character to show.
The character to show will use a shift instruction to shift the bits for the character into the output every 92 ms. Compare for the end of the word (16 bits) or four bits (0000) to determine when to go to the next character.

This is a combination of what Geoff and cardosocea have explained.

Getting the ASCII characters to the FIFO stack can be done by using compares and move statements.

Hope this helps to get you going.
Regards,
__________________
Garry
http://www.accautomation.ca
Connect with us on Facebook: facebook.com/accautomation/
  Reply With Quote
Old January 12th, 2018, 10:22 AM   #5
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Duxford
Posts: 470
Quote:
Originally Posted by gclshortt View Post
A short dash is 10 = E
A long dash is 11011011011011 = number 0
The space between the numbers and character should be set for 0000 = space
Each character is now one word in length.
There isn't any benefit in fitting the pattern in 16 bits apart from saving memory, which shouldn't be an issue nowadays. It will, however, make it a bit more complicated as you need to keep track of two timers.

If however, you have a routine that runs at each 92ms and does the following:

Are there bits to send?
If no then Exit.
If yes then shift next bit into morse output.
Decrement bit counter.
Exit.

The "smart" bit of the logic would be to move the right number of bits into a memory section all in a row. So to send SOS you would have to put in the following bit pattern.
101010111011101110101010

Now we also don't know if the OP is looking for something that is dynamic like someone typing a message to be sent across or if the messages are static in which case this will be the simplest way of doing it.

If the platform accepts indirect addressing down to bit level it would be even better.
  Reply With Quote
Old January 12th, 2018, 10:36 AM   #6
Kevbo
Member
United States

Kevbo is offline
 
Join Date: Aug 2006
Location: Albuquerque,NM
Posts: 21
There is a body of knowledge on this topic in the ham radio community. Specifically memory and keyboard keyers.

A look-up table stores the code for each letter, character, and number. You can save some bits by encoding each element as:

00=end of character
01=dit
10=dah
11=continued in next byte (needed for numerals and punctuation and "packed" messages. ) This last is not needed for a lookup table, but is useful when storing messages as pre-encoded morse.

By dedicating two bits per element, the spacing between elements is inferred, and need not take up a bit. Also dits take the same storage as dahs, rather than dahs needing twice as much, so this conserves 25% memory on average.

This also allows all letters (four elements maximum) to be encoded into a single byte. If the letter has 4 elements, the end of character is inferred. Shorter characters use the 00 code to end early, so proper letter spacing is maintained. The zero-zero code also allows packing messages to achieve better than 1 letter per byte, since morse is intentionally designed so that the most common letters are shorter than than the rare letters. The 11 code allows letters to bridge between bytes when packing, as well as accommodating numerals and punctuation which require 10 or 12 bits to encode.

You can also observe that letters are shorter than numerals and punctuation, so you can split your look up table into two sections with the letter section only needing one byte per character, and the numeral/punctuation having two bytes per character, so your look-up table needs less memory.

Finally, silence is used for spacing between letters and words. In the scheme above, silence between elements and letters can be inferred, but there is no allowance for encoding between words. We can address this by making the first two bits of each byte have special meaning: 11=inter-word space, 00=inter-letter space. Note that this use of 00 is consistent with the end-of-character meaning, as that also infers a between-letters silence.

Edit: I posted this info to tell how hams have worked out a minimum storage space solution, which is useful when implementing a morse device in a low cost microcontroller such as an HC05 or PIC. While the concepts may be handy for PLC implementations, other ways may prove more efficient for programming time, since PLCs typically have significant memory available. At any rate, I find it interesting seeing how something can be optimized.

Last edited by Kevbo; January 12th, 2018 at 11:07 AM.
  Reply With Quote
Old January 12th, 2018, 10:55 AM   #7
gclshortt
Member
Canada

gclshortt is offline
 
gclshortt's Avatar
 
Join Date: Dec 2014
Location: Cobourg
Posts: 2,229
[quote= I'm using Productivity, ...[/QUOTE]

Fitting the characters into the 16 bits is not to save space. This is to simply use the data instructions available in the Productivity Series PLC that the OP is using.

There are multiple Data Types available for configuring parameters and tags within a project.

The Data Types are:
Boolean
Integer, 8 Bit Unsigned
Integer, 16 Bit
Integer, 16 Bit Unsigned
Integer, 16 Bit BCD
Integer, 32 Bit
Integer, 32 Bit BCD
Float, 32 Bit
String
*Constant

* With the exception of a constant data type, each of the above data types are also available as Array data types, one dimensional (1D) Arrays & two dimensional (2D) Arrays.

The arrays is how the information can be obtained.

Regards,
Garry
__________________
Garry
http://www.accautomation.ca
Connect with us on Facebook: facebook.com/accautomation/
  Reply With Quote
Old January 12th, 2018, 07:32 PM   #8
danw
Member
United States

danw is offline
 
danw's Avatar
 
Join Date: Oct 2004
Location: midwest, USA
Posts: 2,704
I haven't a clue for a solution, but I have to ask, Why?
  Reply With Quote
Old January 13th, 2018, 07:57 AM   #9
geniusintraining
Lifetime Supporting Member + Moderator
United States

geniusintraining is offline
 
geniusintraining's Avatar
 
Join Date: Jun 2005
Location: SC
Posts: 5,064
Quote:
Originally Posted by danw View Post
I haven't a clue for a solution, but I have to ask, Why?
I have to agree with Dan... why? you can get a cheap display these days and no need for Morse Code
__________________
www.PLCCable.com PLC Communication Cables, PLC Trainers, Fluke Meters, MicroLogix, ControlLogix, Siemens, Allen Bradley and more... all your automation needs... ((NEW)) After Market 1784-U2DHP Allen Bradley USB to DH+ and Gateways
  Reply With Quote
Old January 13th, 2018, 01:26 PM   #10
AustralIan
Member
United Kingdom

AustralIan is offline
 
Join Date: Jan 2013
Location: UK
Posts: 565
For when you are under a machine with a spanner and your hand up inside holding an M5 nut, and would like to know wether to get your butt up now and go attend the most important machine in the factory, or wether you can tighten your nut first, pack your tools and go attend the cute little machine in the corner that runs 4hrs a day.
Or if you're just closing your eyes to meditate.

Extra challenge: program that Morse code code with your eyes closed.
  Reply With Quote
Old January 13th, 2018, 05:55 PM   #11
Toine
Member
Netherlands

Toine is offline
 
Join Date: Nov 2016
Location: NL
Posts: 148
Quote:
Extra challenge: program that Morse code code with your eyes closed.
Are you essentially proposing IEC-61131-3 should be expanded with programming in Morse?
  Reply With Quote
Old January 15th, 2018, 03:04 AM   #12
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Duxford
Posts: 470
Quote:
Originally Posted by Toine View Post
Are you essentially proposing IEC-61131-3 should be expanded with programming in Morse?
This just raised an image in my mind of people programming in Morse Code through siri...

Dit dat dit dat dat dah dah dit dit. LOLOL
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
test the RSLogix500 code matches with PLC ?? leonlai LIVE PLC Questions And Answers 11 June 29th, 2011 12:41 PM
transfer data code from pc to omron plc ahmed yousri LIVE PLC Questions And Answers 0 March 13th, 2008 06:43 AM
About off-line programming? mayhem LIVE PLC Questions And Answers 18 May 23rd, 2006 04:46 PM
Sub-routines - general question burnerman LIVE PLC Questions And Answers 25 March 2nd, 2006 09:56 PM
How to simulate a FOR..NEXT loop? New2PLCs LIVE PLC Questions And Answers 26 May 9th, 2002 12:36 PM


All times are GMT -5. The time now is 04:26 PM.


.