Schedule Events - help needed :-)
computer guy
Posts: 1,113
Hi there,
I am designing an Irrigation controller that can be programmed via the serial port and a program.
I am wanting as much information as I can get on how to use a "RTC IC"(Real Time Clock) with the propeller to run schedules.
The schedules will be stored in the spare space on the eeprom. <-- Need help here to.
Schedules will be like start at 10:30 run for 30min on area 2.
Does anyone have any suggestions or links to articles that might help.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
I am designing an Irrigation controller that can be programmed via the serial port and a program.
I am wanting as much information as I can get on how to use a "RTC IC"(Real Time Clock) with the propeller to run schedules.
The schedules will be stored in the spare space on the eeprom. <-- Need help here to.
Schedules will be like start at 10:30 run for 30min on area 2.
Does anyone have any suggestions or links to articles that might help.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
Comments
It's a bit older...but you can download examples for it in the parallax site...to use with the BS2's. then modify them for the propeller.
I'm refering to the DS1302... RTC.
Download the datasheet, read it ....read the parallax examples ...they are quiet easy.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
http://pdfserv.maxim-ic.com/en/ds/DS1302.pdf
As for storing the information about the schedule, I'd use a format similar to simple the Linux Cron Tab.
Was just researching USB vendor id's for my controller, for if I decide to go big with them.
Turns out that a USB vendor id costs $2,000USD upwards. Now that isn't cheap.
The BS2 code confused me more than anything, It is code for an alarm but at no pint in the code does it even mention comparing a set time to the rtc time.
Will look into it some more, I might just have to use the DS1302 object from the object exchange and dedicate a cog to comparing the time with an array in the eeprom every 10 seconds.
Will also do some further research into writing to the spare space on the eeprom via the props serial interface.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If I had more than one schedule say 5 of them it would look like this -
15, 30, 60, 2
2, 0, 30, 1
6, 15, 60, 2
13, 0, 60, 3
19, 30, 30, 1
How would I write this to the eeprom(every time the computer sends data) and read it when needed(every 10 seconds).
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
right on top if the forum there is a line
Locked Topic Propeller Announcement, FAQ and Thread Index stickies
that leads you to
http://forums.parallax.com/forums/default.aspx?f=25&m=148376
and there is a link to a thread
Storing Data in Propeller Boot EEPROM
http://forums.parallax.com/forums/default.aspx?f=25&m=162407
i think this can help you
greetings
Stefan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
Post Edited (computer guy) : 1/9/2008 11:32:21 AM GMT
How can I write to certain sections of the eeprom from the computer via the propeller, like the propeller IDE does?
Looks like I have a long road ahead of me, with lots of forks in it.
Oh and BTX, How is that large propeller powered display of yours coming? haven't heard much about it for a while.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
I'd suggest you accept the data from the PC (to the Prop') via the programming connection (maybe using 'simple_serial.spin'?), then use Mikes example to write to the EEPROM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
I have tried to do a similar relaying of data in the past however timing has always been an issue.
In the end I went with the untidy, "send multiple times and hope that the other end receives it at least once" method.
Other then the timing issue, that sounds like a great idea.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
You should be aiming for something like:
1. Listen for incoming data (e.g. using simple_serial)
2. As data arrives, add it to a buffer (say dataIn[noparse][[/noparse]n], where 'n' starts at 0; so dataIn[noparse][[/noparse]0] is first byte received, dataIn is 2nd byte, etc)
3. Once all data has arrived, write it to EEPROM
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
I usually read data in as a variable and then use it immediately.
like -
for i = 0 to 100 {
data = readCom();
Writeeeprom(data);
}
Sorry for the non spin code, was in a rush to respond.
How would I write and read to the buffer?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
I think part of your 'timing issues' may be down to the EEPROM needing ~10ms to write data; your loop's probably not giving it enough time?
HTH
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
first at all a question back
what are your programming-skills?
beginner
some experience in another language like "C", Visual Basic, Pascal, Delphi
much experience in another language
especially with microcontrollers?
beginner
some experience with (what kind of controller?)
if you answer ti this questions the forum can adapt the answers to your skill-level.
some advice from me:
Make your development modular. This means
start with a very very simple program that receives ONE byte and sends back this one byte
to the PC. Save this program with a name like Serial1ByteDemo.spin
If this is working make a small program only receiving and sending back a string.
If this is working create a small program that just is writing and reading back some bytes to the EEPROM
Save it as ReadWriteEEPROM-Demo.spin
make every function like "receiving one serial byte", "receiving a schedule-string", "readEEPROM-Byte", "save-EEPROM-Byte", "save ONE Schedule-Dataset to EEPROM"
their own PUB-procedure
This makes it possible to test every function itself
If the function is tested and OK you are sure this part works properly
Then it will be much easier to find bugs in your code
If this is working bring together 10 Byte receiving and read/write to EEPROM
etc. etc.
Now to SPIN-Code examples:
There are some propeller-objects you can use
in the propeller-tool-folder there is a file fullduplexserian.spin
the code of this objects manages the details of the serial communication
It has a buffer of 16 bytes. It is possible to change this value up to 256 bytes.
(but you have to change values in the ASM-Code too !)
This buffer is managed by the object itself. Only if you send more than 16 bytes
the oldest bytes were overwritten.
So as long as you need not more than 16 bytes for one schedule-entry you don't need to code a second buffer
in your program.
To make it more secure you could create a simple software-handshaking by sending back an acknowledge-byte
to say the PC "OK i (the prop) stored the last byte you can send me (the prop) the next byte
in the object-exchange
http://obex.parallax.com/
there is an object
Extended Full Duplex Serial
it has functions that work similar to your example "readCom()"
But be aware of: the propeller manages directly only longs, strings are managed like in "C" as zero-terminatet strings handled by pointers
So one easy solution could be receiving one byte of the schedule-data and then store it into the eeprom then the next byte an so on
If you hurry up throwing all functions "receive serial byte", "readEEPROM-Byte", "save-EEPROM-Byte" into two big loops trying to save time
you will loose three times more time for debugging that mess of code.
Every function its own PUB-procedure is much more effective.
greetings
Stefan
I would set up the communication as a message, with a beginning, a data portion, and an end. The beginning would be some value that the Prop uses to identify the start of a message,and an indicator of the message length. The end would be an "end of message" indicator, perhaps preceded by a checksum of some sort. In between is your data. Once you have identified your maximum message length, set up a buffer (array) in the Prop into which you can easily dump the message directly from the serial object with a small loop (then you don't need to worry about the size of the receive buffer in the serial object). Use your message length indicator as a counter for your loop. After you have received the entire message, check your checksum (if implemented), save it to eeprom and send an acknowledgement message back to the PC to confirm success.
I have not had much luck with the SimpleSerial object (at least at 9600 baud) because I didn't have enough time between received bytes to do anything with the data. I suggest using FullDuplexSerial because the critical areas are written in ASM and it has a buffer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
I am writing my own program in c#.
I am new to this language but have had success with getting the basics for my program started and am currently in the process if writing the serial part of it.
Thank you for sharing your thoughts on SimpleSerial and FullDuplexSerial.
Stefan,
Ok, I have done about 6months playing around with C++ about 5 years ago.
I am learning C# now and only started a few weeks ago.
I have done a bit of programming in spin, just general pwm and reading inputs setting outputs and pausing, still learning as I go.
I used the BS2 for a few months, learnt the general language and then moved on to the propeller for my robot project (in my signature below).
Thank you I will definitely start with a few small programs to test the functionality of the individual functions before going big.
Simonl,
Thank you, along with the code sample you provided and allot of code that... Mike Green (I think) Provided a while ago I think I am on the right track.
Thank you all
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR