Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 20
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
One birthday today, congrats!
Vaxian (17)


Next birthdays
05/21 Dalus (34)
05/21 Kizmo (37)
05/22 Skynet (32)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

How to structure a program

1 2 
Move Thread LAN_403
rp181
Mon May 03 2010, 10:45PM Print
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
I am working on a system in which the slave processor (mbed) streams sensor data (wireless), where a the master (a normal pc/laptop) does the necessary computations and streams instructions back. The problem is I need to [effectively] do both sending the data and receiving the instructions at the same time. If I used a single interrupt for the receiving, then I would get it sending a chunk of data, receiving instructions, and resuming data sending, which would cause incomplete data sets, and a way too long cycle time. The output as determined by the instructions (servos) need to constantly be adjusted, and control needs to be held.

How would I go about doing this on a single core platform? Could I split the rx/tx of the transmitter to different processors somehow (as in one processors only sends data, one only receives)?

-Ravi
Back to top
Bjørn
Tue May 04 2010, 05:18AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
A PC is extremely fast compared to the time it takes to transmit one byte, it can compute a medium sized mandelbrot set while waiting for the next byte and still have to wait. So there is no chance of any data getting lost if you code it properly.

You have two choices, either make a single loop or use multi threading. Both has their share of problems. The single loop is more complicated and multi threading is more confusing since you are never sure what is going on since you have two things going on at once. If it is all on one device like a serial port you may have further complications with trying to share it between two threads.

If you use operating systems like Linux or Windows you have no guarantee that you will not get pauses in your processing, for that you need a real time operating system or something simple like DOS where you can disable the interrupts and be sure.

Now we need more information about the interface, the OS, the programming language and your requirements.
Back to top
Carbon_Rod
Tue May 04 2010, 06:55AM
Carbon_Rod Registered Member #65 Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
Almost all high bandwidth systems use timestamps, data chunk index numbers, and a nonce.

This means that it's possible to logically coordinate several data sources into a single "event". Avoiding capturing everything at the same time means the data becomes much easier to manage.

Also, most wireless communication can be several times less efficient for communication, and will often resend a wireless frame up to 7 times before the TCP layer gets involved. The actual throughput ideally should be about 60% of the rated speed. Note that many wireless connections are likely half duplex in the PHYS layer.

What type of connection do you plan to use?
Back to top
rp181
Tue May 04 2010, 12:09PM
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
The PC programming will be easy, It will be multi threaded. It will be implemented in this program:
Link2
My problem lies in programming the single thread . The base programming (The part I dont have problems with) will be java on a linux machine. The processor I am asking about is a LPC1768, programmed in C. The Wireless link consists of two Digi-xTend's, which specify a max baud rate of 115,200bps.

I have not heard of a nonce before, I will look into that.
Back to top
Steve Conner
Tue May 04 2010, 04:39PM
Steve Conner Registered Member #30 Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
Here are some things you need to investigate:

Is your wireless link full duplex or half duplex?

What's the packet size?

What's the latency?

What's the frame size of your protocol?

How much latency can your control system tolerate?

It's probably half duplex, because a radio that can transmit and receive at the same time is more expensive than an ordinary one. In this case you have no option but to send a chunk, receive a chunk, turn about. Buffering can give the illusion of full duplex, at the expense of extra latency, the amount of latency depending on the chunk size.

Back to top
rp181
Tue May 04 2010, 11:38PM
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
I had not been able to find much information on these modules, but I was able to find much more by searcing under their old company name (I am using digi/maxstream 900mhz xTend modules). I found this post on RC groups:
The Maxstreams are a good choice. The end to end latency is about 64 Ms. on our system. This includes:

1. decoding first 5 channels of multiplexed servo output from RC trainer port
2. creating packet with servo data
3. sending packet to modem over UART at 115200
4. Over the air latency - Maxstream says 9.4 ms - probably a tad higher depending on where in the hop sequence the data arrives.
5. shifting in the packet on the autopilot UART - 115200
6. decoding the packet (we check the uart every 20 ms)
7. adding rate damping (again 50 hz main loop)
8 writing to servos

All this in about 60 ms. Not bad - I am sure if we did not gaurantee the main loop timing and did not have to do all the other autopilot related tasks we could speed this up a bit.

When the maxstream modems are replaced by a wire, the latency does not improve much - Confirming that most of the latency is in waiting for the 50 hz main loop to finish, etc., not the over the air transmition.

BTW, we run the Xtend modems in full duplex, broadcast mode with 2 broadcast attempts.


Thanks for the info on the Digi modems.

Reed
From the datasheet:

The data flow sequence is initiated when the first byte of data is received in the DI Buffer of the
transmitting module (XTend RF Module A). As long as XTend RF Module A is not already receiving
RF data, data in the DI Buffer is packetized then transmitted over-the-air to XTend RF Module B.

So it looks like its half-duplex, but still pretty low latency.
The program will need to do the following:
Collect data from 10 sensors (Have not decided on frequency, probably around 50hz). Transmit. A GPS coordinate comes along every second (minimal GPS string parsing).
Meanwhile, it needs to receive servo control instructions, and execute. The problem is the hold on the servos can not be stopped. I may have to bias the output with a positive voltage.

I have been looking around and came across XMOS chips. These look great, and I have been wanting to try multi threaded neural networks. What do you think of XMOS chips?
The only thing I can't figure out is if one XMOS will support 2 (full duplex for wireless, half duplex for GPS string input) UARTs. XMOS chips input pins are only 1 bit IO, and they are configured in software to group it for 4,8,16 bit collections ,and to act as various digital inputs (i.e. 4 digital pins are driven to act like a SPI port for the flash memory). Any advice on XMOS chips? It seems like a interesting thing to try.
EDIT: DS specifies 9.4ms latency in unidirectional comm. Datasheet link:
Link2
Back to top
Bjørn
Wed May 05 2010, 07:46AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
The XMOS is great, you can program it to do anything and support any number of ports since it is all done in software using their event driven mechanism. The downside is that the number of possible solutions to your problem is now infinite and you need a very good focus to keep on track.

To stop dithering and get on with it you can do this where every function keeps a state so it can do a partial job then return:

Do
  Collect data from sensors
  Transmit data
  Receive GPS data
  Parse GPS data
Loop
Figure out the minimum loop frequency, for example the FIFO on the serial port is 16 bytes long so the loop must be fast enough that it does not overflow at the baudrate you use.

When you have mapped out all this in some detail you can decide if you want to use interrupts and run some or all of this in separate "threads". It is impossible to say what is easiest without knowing a lot more of the requirements.
Back to top
Steve Conner
Wed May 05 2010, 09:18AM
Steve Conner Registered Member #30 Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
rp181 wrote ...

The problem is the hold on the servos can not be stopped. I may have to bias the output with a positive voltage.
Can you explain what this sentence means? It makes no sense to me at all. I think if you tried to explain it to us, you would end up understanding the problem better yourself.
Back to top
rp181
Wed May 05 2010, 12:18PM
rp181 Registered Member #1062 Joined: Tue Oct 16 2007, 02:01AM
Location:
Posts: 1529
I dont think I have said yet, but this is a attempt at a helicopter autopilot. The servos control the pitch of the blades. If the servos are not constantly adjusted, then the will slack and the rotor with lose any pitch, causing a crash.
(Unless servos hold their position? Never really used servos.)
I need to get ahold of some servos to try it out, I am just trying to some pre-planning now.
Thanks for the help.
Back to top
Bjørn
Wed May 05 2010, 01:25PM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
RC servos go to the position they are ordered. If it is the PWM type you feed them with a constant 50 Hz signal using the PWM units on your microcontroller. Then you update the PWM registers when you want a change in position.
Back to top
1 2 

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.