PDA

View Full Version : UNICOM - New universal asynchronous serial communications object proposal



Peter Jakacki
12-24-2009, 11:34 AM
I have been meaning to place some of my serial comms methods into the obex but having time to play and tidy up code is usually way down on the list. However at the moment I have some time and in tidying up one object for RS485 use I decided to unify the serial comms routines I use into one universal object. Of course nothing is ever universal but this one covers all that I need to do which is usually a lot more than most forum members require. Most of these features have been implemented and some have to be finalized and tested but all have to be massaged into a simple and sensible object interface. If you think that it would be nice for some other feature to be included or modified then let me know.

The aim of this object is to encapsulate the methods in such a way that the object itself does not need to be tweaked, that is, the user program supplies the compile-time switches and run-time parameters. This object is designed for the extra functions that BST provides so it won't run in it's original form on the Propeller Tool. Besides, BST is a multiplatform IDE and penguins rule here as my computers run Linux as the main O/S. If the OBEX is picky about this then maybe we should have a location for objects and examples in general. I have just setup a group to collect all those odd files that are not part of the obex at Google and Yahoo, any opinions ? Rough setup for evaluation at groups.google.com.au/group/propfiles (http://groups.google.com.au/group/propfiles) and tech.groups.yahoo.com/group/propfiles/ (http://tech.groups.yahoo.com/group/propfiles/)

By default if only the "start" method is used the object will behave just like the FullDuplexSerial object with it's own buffers etc. Using a compile time switch the user may specify external buffers and sizes. Constants cannot be passed to an object at compile time so the buffer pointers and sizes are initialized at run-time by the user program if desired. Setting databits to more than 8 bits will cause the driver to assign multiple bytes to each "character" which will be read and written as one word.

I will probably do an first release and then keep testing and adding additional features. I know some have released serial drivers but I'm not sure what features they have and besides trying locate the original threads again is a pain.

Here's a very quick overview:

UNICOM ASYNCH - Universal Asynchronous Serial Communications Object (Compiles under BST)

Features:
* Object method to set buffer sizes with user supplied buffers (defaults to internal buffers)
* Variable data bits up to 32 bits
* Variable transmit stop bits (default 1) - can also be used for pacing characters - receive only expects one stop bit.
* Full/Half-duplex modes
* Operation to in excess of 1Mbit (half-duplex)
* High-speed mode 10Mbit mode (half-duplex) - modified version of Brandon Nimon's code integrated into driver.
* RTS/CTS control or XON/XOFF control with configurable triggers (default none)
* RS-485 support (combo rx/tx or independent pins)
* Parity generation and detection
* Break generation and detection action (reboot etc)
* Command sequence detection and action (gap...sequence...gap) - This allows the serial cog to perform an action independently of the main program
* Packet support
- Gap detection and action (Start frame, signal end-of-frame etc)
- Checksum and CRC generation and reception
- MODBUS RTU support - Automatic start of frame and checksum
- 9-bit mode address wakeup
* ANSI drawing and general commands (PLAIN, REVERSE, BOLD, FG, BG, RECT, LINE, large BLOCK characters, etc)
* Object access methods include access to control and status registers and read features & version

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Cluso99
12-24-2009, 02:13 PM
Peter: FYI here is a modified version of FDX that I use (variable size buffer and fdx.rxavail)

One of the annoying things I find is that I would like to be able to substitute the object from keyboard/video to serial and back again easily. For example, fdx.tx vs tv.out

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBlade (http://forums.parallax.com/showthread.php?p=786418),·RamBlade (http://forums.parallax.com/showthread.php?p=849265),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) (http://forums.parallax.com/showthread.php?p=778427) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)
· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

pacman
12-25-2009, 05:03 AM
Peter Jakacki said...
br>
Features:
* RS-485 support (combo rx/tx or independent pins)
* Parity generation and detection
* Packet support
- Gap detection and action (Start frame, signal end-of-frame etc)
- Checksum and CRC generation and reception
- MODBUS RTU support - Automatic start of frame and checksum
-


Ohh..release soon ,Please....

Modbus RTU .....

http://forums.parallax.com/images/smilies/yeah.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================

Bill Henning
04-01-2010, 10:41 PM
Hi Peter,

You made me drool over UNICOM in my PropCade thread... and now I find it even has Modbus support! I used to work with Modbus, Modbus+ and Modbus/TCP a LOT.

I quickly jumped over to the two groups you mentioned to look for the files... alas, they are MIA.

Please release this soon!

(Excellent work, btw)

Thanks,

Bill


Peter Jakacki said...
I have been meaning to place some of my serial comms methods into the obex but having time to play and tidy up code is usually way down on the list. However at the moment I have some time and in tidying up one object for RS485 use I decided to unify the serial comms routines I use into one universal object. Of course nothing is ever universal but this one covers all that I need to do which is usually a lot more than most forum members require. Most of these features have been implemented and some have to be finalized and tested but all have to be massaged into a simple and sensible object interface. If you think that it would be nice for some other feature to be included or modified then let me know.

The aim of this object is to encapsulate the methods in such a way that the object itself does not need to be tweaked, that is, the user program supplies the compile-time switches and run-time parameters. This object is designed for the extra functions that BST provides so it won't run in it's original form on the Propeller Tool. Besides, BST is a multiplatform IDE and penguins rule here as my computers run Linux as the main O/S. If the OBEX is picky about this then maybe we should have a location for objects and examples in general. I have just setup a group to collect all those odd files that are not part of the obex at Google and Yahoo, any opinions ? Rough setup for evaluation at groups.google.com.au/group/propfiles (http://groups.google.com.au/group/propfiles) and tech.groups.yahoo.com/group/propfiles/ (http://tech.groups.yahoo.com/group/propfiles/)

By default if only the "start" method is used the object will behave just like the FullDuplexSerial object with it's own buffers etc. Using a compile time switch the user may specify external buffers and sizes. Constants cannot be passed to an object at compile time so the buffer pointers and sizes are initialized at run-time by the user program if desired. Setting databits to more than 8 bits will cause the driver to assign multiple bytes to each "character" which will be read and written as one word.

I will probably do an first release and then keep testing and adding additional features. I know some have released serial drivers but I'm not sure what features they have and besides trying locate the original threads again is a pain.

Here's a very quick overview:

UNICOM ASYNCH - Universal Asynchronous Serial Communications Object (Compiles under BST)

Features:
* Object method to set buffer sizes with user supplied buffers (defaults to internal buffers)
* Variable data bits up to 32 bits
* Variable transmit stop bits (default 1) - can also be used for pacing characters - receive only expects one stop bit.
* Full/Half-duplex modes
* Operation to in excess of 1Mbit (half-duplex)
* High-speed mode 10Mbit mode (half-duplex) - modified version of Brandon Nimon's code integrated into driver.
* RTS/CTS control or XON/XOFF control with configurable triggers (default none)
* RS-485 support (combo rx/tx or independent pins)
* Parity generation and detection
* Break generation and detection action (reboot etc)
* Command sequence detection and action (gap...sequence...gap) - This allows the serial cog to perform an action independently of the main program
* Packet support
- Gap detection and action (Start frame, signal end-of-frame etc)
- Checksum and CRC generation and reception
- MODBUS RTU support - Automatic start of frame and checksum
- 9-bit mode address wakeup
* ANSI drawing and general commands (PLAIN, REVERSE, BOLD, FG, BG, RECT, LINE, large BLOCK characters, etc)
* Object access methods include access to control and status registers and read features & version

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com 5.0" VGA LCD in stock! (http://forums.parallax.com/showthread.php?p=852195)
Morpheus (http://mikronauts.com/products/morpheus/) dual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory/IO kit $89.95, both kits $189.95 SerPlug $9.95 (http://mikronauts.com/products/serplug/)
Propteus (http://mikronauts.com/products/propteus/) and Proteus (http://mikronauts.com/products/proteus/) for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Dave Hein
04-02-2010, 03:06 AM
I included your first item in cserial.spin, but I don't think I have any of the other features you listed.· A few other features that might be useful are:

1. Echo back the received character

2. A received backspace character removes the previously received character and send BS, SP, BS to output

3. Enable multiple serial ports per cog with an aggragate TX/RX rate of 500 kbps

4. Optional use of a lock for multi-cog access

Items 1 and 2 are useful for console I/O.· Item 3 would allow several low rate serial ports in one cog.

simonl
04-02-2010, 06:40 AM
@Peter: This is just EXCELLENT http://forums.parallax.com/images/smilies/yeah.gif Me wants it now please!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
-------------------------------

www.norfolkhelicopterclub.com (http://www.norfolkhelicopterclub.com)

Announcement: To cut costs in the current economic climate, we have switched-off the light at the end of the tunnel.

computer guy
04-29-2010, 06:52 PM
@peter

I too would like this. Please release it soon. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here (http://forums.parallax.com/showthread.php?p=847513)
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net (http://www.ecosureblog.net)

The Sarah Myatt Fund - Help Sarah and Her Family Fight Quadriplegia HERE (http://www.thesarahmyattfund.com)

BTX
04-30-2010, 12:01 AM
Hi Peter.
Impressive characteristics !!! I want it now !!!
Well done.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.

Alberto.

Peter Jakacki
04-30-2010, 07:29 AM
Alberto, you always want it now http://forums.parallax.com/images/smilies/smile.gif

I meant to finish it this month but I have been sidetracked this past week doing my new PUPPY Prop module. Some of those serial functions could be handled nicely by the PPC on the module and I am quite tempted to do so but we still need an object for stand-alone Props too (back to the real world). I will try to get the object polished and tested in the next week or two.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

william chan
04-30-2010, 07:35 AM
Would having so many features make the object bloated?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my (http://www.fd.com.my)
www.mercedes.com.my (http://www.mercedes.com.my)

Peter Jakacki
04-30-2010, 08:08 AM
Once you have dedicated a cog to PASM it doesn't matter really whether the cog is only using 10% or 100% of it's memory. There is the DAT image in HUB memory which I would like to structure using BST in such a way that it can be reclaimed, but this is something that is common with all PASM objects. Anyway, a design well done will always be simple and functional, never bloated (as in a lot of wind).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

BTX
04-30-2010, 08:12 AM
Peter, yes I always want all now, and yet haha... http://forums.parallax.com/images/smilies/lol.gif
Be carrefully, with your PUPPY prop module you'll send me to bankrupt too http://forums.parallax.com/images/smilies/smile.gif Looks really great, and your suggested price is impossible.
How do you do that ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.

Alberto.

James Newman
04-30-2010, 08:13 AM
I could really use the modbus support... so I'm another eagerly awaiting member. :)

Peter Jakacki
04-30-2010, 09:09 AM
BTX said...
Peter, yes I always want all now, and yet haha... http://forums.parallax.com/images/smilies/lol.gif
Be carrefully, with your PUPPY prop module you'll send me to bankrupt too http://forums.parallax.com/images/smilies/smile.gif Looks really great, and your suggested price is impossible.
How do you do that ?


How do I do it? Not easy, the price is really low and my margin is really slim but choosing the right components in the right quantities makes it easier. I want to try to keep it low though. The Silabs chip has bumped up my cost a little and just now I have done some more research and found an AT XMEGA A4 chip which is almost half the price and I think it's a lot better.....what to do? Oh, the humanity!

I want all this stuff now too, only trouble is I have to get up and put my nose to the grindstone to get it http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Bill Henning
06-01-2010, 01:01 AM
Hi Peter,

Any news on your comm object?

Regards,

Bill


Peter Jakacki said...

BTX said...
Peter, yes I always want all now, and yet haha... http://forums.parallax.com/images/smilies/lol.gif
Be carrefully, with your PUPPY prop module you'll send me to bankrupt too http://forums.parallax.com/images/smilies/smile.gif Looks really great, and your suggested price is impossible.
How do you do that ?


How do I do it? Not easy, the price is really low and my margin is really slim but choosing the right components in the right quantities makes it easier. I want to try to keep it low though. The Silabs chip has bumped up my cost a little and just now I have done some more research and found an AT XMEGA A4 chip which is almost half the price and I think it's a lot better.....what to do? Oh, the humanity!

I want all this stuff now too, only trouble is I have to get up and put my nose to the grindstone to get it http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus (http://mikronauts.com/products/morpheus/) / Mem+ (http://mikronauts.com/products/morpheus/memplus/) / PropCade (http://forums.parallax.com/showthread.php?p=894725) / FlexMem (http://forums.parallax.com/showthread.php?p=894853) / VMCOG (http://forums.parallax.com/showthread.php?p=878382) / Propteus (http://mikronauts.com/products/propteus/) / Proteus (http://mikronauts.com/products/proteus/) / SerPlug (http://mikronauts.com/products/serplug/)
and 6.250MHz Crystals to run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/) & 5.0" OEM TFT VGA LCD modules (http://forums.parallax.com/showthread.php?p=852195)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Peter Jakacki
06-01-2010, 04:57 AM
I have a whole list of objects and projects that I "intend" to work on active both in my browser and in BST. So far the intention is good but I will make sure I devote some time to it this week to post something functional. Is there any particular feature that you are really after Bill?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*

Bill Henning
06-01-2010, 05:15 AM
LOL I *KNOW* that feeling...

Yes, two features in particular:

RS485 with combined rx/tx
Modbus RTU

I have four products with RS485 chips coming out at UPEW... PropCade, 485Plug, and a surprise or two :)


Peter Jakacki said...
I have a whole list of objects and projects that I "intend" to work on active both in my browser and in BST. So far the intention is good but I will make sure I devote some time to it this week to post something functional. Is there any particular feature that you are really after Bill?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus (http://mikronauts.com/products/morpheus/) / Mem+ (http://mikronauts.com/products/morpheus/memplus/) / PropCade (http://forums.parallax.com/showthread.php?p=894725) / FlexMem (http://forums.parallax.com/showthread.php?p=894853) / VMCOG (http://forums.parallax.com/showthread.php?p=878382) / Propteus (http://mikronauts.com/products/propteus/) / Proteus (http://mikronauts.com/products/proteus/) / SerPlug (http://mikronauts.com/products/serplug/)
and 6.250MHz Crystals to run Propellers at 100MHz (http://mikronauts.com/products/mikronauts-625mhz-crystal/) & 5.0" OEM TFT VGA LCD modules (http://forums.parallax.com/showthread.php?p=852195)
Las (http://mikronauts.com/software-products/largos/) - Large model assembler Largos (http://mikronauts.com/software-products/largos/) - upcoming nano operating system

Post Edited (Bill Henning) : 5/31/2010 10:55:09 PM GMT

Bill Henning
09-29-2010, 11:00 PM
Hi Peter!

Any progress with UNICOM?

Thanks,

Bill


I have a whole list of objects and projects that I 'intend' to work on active both in my browser and in BST. So far the intention is good but I will make sure I devote some time to it this week to post something functional. Is there any particular feature that you are really after Bill?

*Peter*

Heater.
09-30-2010, 03:57 AM
Peter Jakacki (http://forums.parallax.com/member.php?u=47248)

UNICOM sounds really neat.

There is one important thing I would like to see. The possibility to use the compiled PASM code, as extracted with BSTL without any dependence on Spin. That is to say that all parameters go in to PASM via PAR and when running the only interaction with the outside application is through a given memory area. Plus there would be no "poking" of parameter LONGs into the DAT section prior to loading it to COG.

This kind of interface is required such that an object can be used with languages other than Spin. In my case C or C++ running under the Zog interpreter. But this kind of interface has been discussed a few times on the forum by others, for example in connection with reusing objects with PropBASIC or Catalina.

Dave Matthews
10-03-2010, 04:26 PM
Any propeller MODBUS support objects yet?

"- MODBUS RTU support - Automatic start of frame and checksum"

Thanks,
Dave

Peter Jakacki
10-07-2010, 05:48 AM
Update:

I have been playing with other micros lately and haven't had that much time to spend on the Prop :( However, just the other day I updated my serial drivers as I needed some high-speed serial and precise bit-timing (start bit, sampling offset etc). By using self-modifying PASM code I was able to run over 2M baud easily although at this speed the driver splits this onto dedicated cogs (oh well).

I will look into optimizing this a little bit more and taking in some of the suggestions and requests as I integrate these routines into UNICOM. So sometime in the next week I will be able to post an object.

Any suggestions on how users would like to talk to MODBUS devices from the application? I have implemented several custom methods which also involve master/slave and MODBUS over Ethernet but they aren't really for general use.

Dave Matthews
10-13-2010, 12:08 PM
My application requires writing position values to the slave's MODBUS registers, reading speed and other values from the slave's MODBUS registers, and finally reading and writing various 'coils' in the slave. I'm prepared to write the routines required, but if you are close to releasing something I can wait.
Dave



Update:

Any suggestions on how users would like to talk to MODBUS devices from the application? I have implemented several custom methods which also involve master/slave and MODBUS over Ethernet but they aren't really for general use.

electromanj
10-26-2010, 01:34 PM
Hello! Just wondering how your coming along with unicom.

Peter Jakacki
10-29-2010, 09:31 AM
Hello! Just wondering how your coming along with unicom.

Well.............just prioritizing my work but I have been working on various components especially high-speed serial. I have been playing with a new logic analyzer that can view timing information in various formats including serial data. What I am working on now is improving the throughput at high speeds as although some objects may work at high speeds they may not be able to do so under a sustained load. This means back-to-back character reception and transmission which means buffering in the cog's memory and using simple memory access for Spin etc.

Thanks for the interest, I will post some code soon.

ghost2
02-02-2011, 12:21 PM
Apologies for bouncing this thread, but I am really curious about any progress.

Best regards,

ghost