SimpleIDE PWM
AS
Posts: 149
in Propeller 1
I´m looking for a simple example to change the intensity of a led with PWM, I can´t found any.
I do this with SPIN and I want to know how use PWM with SimpleIDE.
I think is something with
I do this with SPIN and I want to know how use PWM with SimpleIDE.
I think is something with
pulse_out (int pin, int time)Thanks
Comments
I think there's a way to search SimpleIDE for these functions too, but I just searched "pwm" at the top-right of http://david.zemon.name/PropWare and found this
http://david.zemon.name/PropWare/simpletools_8h.xhtml#a57f683188c3dd35ee0574ff349835682
I will try do something simple. I ask it here without try nothing, because I thought that should be a example in the (http://learn.parallax.com).
This code is working ok:
I have two simple questions for now:
1 - The channel of pwm_set can be "0" or "1" it is the Counter Modules for each COG "ctra" and "ctrb". Right?
2 - Now I´m trying to control the Led with the LabView, at this moment I have only one question.
How I should to do to convert a string from the array to a integer? In the Arduino I do something like: Where can I see information to convert strings and numbers?
Thank you
Or that's the equivalent of
This is because the ASCII value for a zero is 0x30. And the ASCII value for a one is 0x31. See http://www.asciitable.com/.
Of course, you might notice this only works for single digits
If you need a solution that works for many digits, but always whole numbers and only numbers, then you can use atoi (array to integer) or atol (array to long).
Notice that this time I did not use c[index], but c instead. This is because atoi and atol require "C-string"s. That is another way to say "null-terminated character array". Or, more importantly, more than a single character. Most of time, this is how people deal with input from the terminal: they read in whole strings at a time, rather than individual bytes. So, this method is easier than the first that I mention, but it requires modifying the rest of your code to read strings instead of bytes from LabView.
Finally, there's sscanf. This is like the reverse of printf. You give it a formatted string and it breaks up the words into the values you want. I wouldn't recommend it for this specific application, but the documentation is worth a glance so that you know what tools are in your toolbox
I don't have the code in front of me, so I can't confirm it... but your guess sounds like a very good one to me.
I need your help!
The LabView is sending something like:
"ok0," or "ok78," or "ok675," or "ok1000,"
I can change it, if you think usefull.
I go post the code just for you laugh a little , the real reason is to let you understand how I´m thinking to do this , of course when this run it is possible to simplify.
I think the best solution for me is to do something like: Because I want send numbers and letters each cycle!? (from the LabView)
I think I don´t understand when you said: "highly inflexible" :P, I already done similar tasks with SPIN and C (to Arduino) and I think it was much easier, maybe because are more information and examples. I hope you can help me!
Thanks
Any sugestion? Please!
The following code shows what I mean, but be aware that it's untested:
Andy
At this moment your code is not working right, I will see it better and I will have some question about it for sure :P
I´m getting some issues with the "getChar()" I think I will need use "fdserial".
Thanks a lot for the example you sent.
At brief glance, ariba's code looks good (as usual ). The only issue I see right away is that he mixed cases on the getChar. Perhaps that is the issue you're running into?
Thanks a lot (again) your code is Fantastic!
I learn with your code. But I don´t understand why "gerchar()" is not working here
The code that is running here is with "fdserial.h":
Ariba and DavidZemon, I hope you can help me understand what is the issue with "gertchar()"
DavidZemon I want to see PropWare running this, I want try it, but at this moment I need to understand the other issue (http://forums.parallax.com/discussion/163457/simpleide-fdserial-h#latest).
Your help has been fantastic!
The issue here is very similar with the other one (http://forums.parallax.com/discussion/163457/simpleide-fdserial-h#latest). With "fdserial.h" is everything ok but with "getchar()" I just can´t understand why it is not working.