My first attempt at Spin
Pablo1234
Posts: 19
ok hear is my code, I'm trying to emulate my pbasic code I wrote weeks ago.
the concept is that lfo1Amp will contain an 8 bit integer that I will send to a I2C DAC with some more code. I want access to the freq (.084mS - 10,000 mS) and duty of the triangle wave without changeing the Freq or phase. I do understand I could do this alot easyer with cnta in duty mode but I want to start my prop exp with trying to convert my pbasic code and adding features.
please give me comments I havent had time to upload this to my prop yet and won't till next thursday, I'm haveing twins in 2 weeks so my wife has me doing all kinds of fun things around the house.
I know its slopy and clumsy but its my first atempts at SPIN.
found some bracket errors i fixed at the end.
another edit, I addid bit reduction and bias settings and some description notes
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A woman is the only thing I am afraid of that I know will not hurt me. - Abraham Lincoln
http://www.youtube.com/user/Pablos0071·projects I have worked
Post Edited (Pablo1234) : 5/26/2010 2:22:18 PM GMT
the concept is that lfo1Amp will contain an 8 bit integer that I will send to a I2C DAC with some more code. I want access to the freq (.084mS - 10,000 mS) and duty of the triangle wave without changeing the Freq or phase. I do understand I could do this alot easyer with cnta in duty mode but I want to start my prop exp with trying to convert my pbasic code and adding features.
please give me comments I havent had time to upload this to my prop yet and won't till next thursday, I'm haveing twins in 2 weeks so my wife has me doing all kinds of fun things around the house.
I know its slopy and clumsy but its my first atempts at SPIN.
found some bracket errors i fixed at the end.
another edit, I addid bit reduction and bias settings and some description notes
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A woman is the only thing I am afraid of that I know will not hurt me. - Abraham Lincoln
http://www.youtube.com/user/Pablos0071·projects I have worked
Post Edited (Pablo1234) : 5/26/2010 2:22:18 PM GMT
Comments
Good luck with the twins.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A woman is the only thing I am afraid of that I know will not hurt me. - Abraham Lincoln
http://www.youtube.com/user/Pablos0071·projects I have worked
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A woman is the only thing I am afraid of that I know will not hurt me. - Abraham Lincoln
http://www.youtube.com/user/Pablos0071·projects I have worked
I can't see your code - could you kindly re-post it so that we can take a look?
Regards,
T o n y
I'm almost everyday in this forum for three years know and I haven't seen this question before.
You seem to have a healthy selfconfidence and I appreciate this kind of asking very much.
OK, so as long as we wait for the code beeing reposted or even better re-attached a hint about execution-time
Do you have an oscilloscope? If yes you could add a line of code that does toggle an IO-pin by xor-ing the corresponding bit of an IO-Pin in the OutA-register
and then measuring the frequency
Another approach could be to start a frequency measuring code in a second cog (which in fact runs completely independent from the other code as the standard-case)
and measure the frequency of the bit toggling with that code. Then execution-time is 1/freq
I understand the basic thing of what you are doing. But with the small comments you made in the code it would take me an hour to understand what is going on in your code.
Which line of code does what?
I enjoy researching solutions to questions if I understand the details of a problem within 5 minutes even if the research or writing samplecode takes two hours.
As this forum is a free thing to answer or not I feel free to do it that way.
best regards
Stefan
In many of my programs, I use code like this:
If you use the SimpleSerial object or TV object to send the results to either the PropSerialTerminal or to a TV, you can see exactly how many clock cycles the code took to execute.· Since you know what your clock speed is, you can easily convert the result to seconds.· I usually leave the result in cycles, because it's more accurate when measuring my code optimization efforts.
Note that there will be some overhead involved in taking the measurement, but you can figure out what that is by doing this:
For most things this wouldn't matter, but if you're measuring a very small amount of code it might be useful.
Jason
·
Just a little addendum to make it clear for everyone, if you need adequate time-measurement the full sequence looks like that
In the example you gave (repeat ... + call function) the repeat and call time is included as well. So, if you are really interested in the pure runtime of the function you can include the repeat 10 between StartTime and MeasurementOverhead. This subtracts the time for the repeat handling. And if you like you can also call an empty function with the same number of parameters, which also eliminates the overhead for preparing the call stack, call the function and return. Then you really get a number which tells you how long the code inside the function took.
Surely it's obvious to all the skilled people here, but my feeling is that there·might some who'll·be happy for·the pointer.
Post Edited (MagIO2) : 5/27/2010 7:17:04 AM GMT