I am presently using IDE version 5.3.1.0 with an Atom 28 on a mini ABB.
I finally got the onboard speaker to work in the Rover ps2rov4 program by treating the sound duration as us and not as ms (Thanks Jim).
The program works great as written except that I had to take out the PAUSE 20 at the end of the servo PULSOUT commands to keep the PAN/TILT servos (Hitec 422s) from oscillating (vibrating) when powered by 6 volts
The sethserial and hserout are not blue as other commands are indicating that the Compiler thinks are are unrecognized tokens.
Is there some kind of hardware serial initialization besides the sethserial that needs to be done so that the Complier will recognize sethserial and hserout as commands and not unrecognized tokens?
The pause 20 is required, unless you have modified the code in a way that the loop time between running the pulsout command has been increased. Bottom line is the pulses should be generated every 20mS. Having the pulses generate faster than 20mS apart may shorten the life of the servo.
It possible that you have used a serout to a terminal window as a way to debug your code. If that’s the case, there’s your additional delay that required you to remove the 20mS pause. Using the serout as a debug will affect the loop time of the program adversely. Unless it’s required in the program I would remove it as soon as it is no longer necessary.
Yes, you must have ENABLEHSERIAL somewhere in your code otherwise the library for the hserial commands will not be loaded and trying to use hserin/out or sethserial will cause errors.
Note: there are hserial commands for the regular Atom as well.
The pan and tilt servos were oscillating or shaking with the original ps2rov4 program with no debug or terminal output. I do have a terminal output now in the program, but have not noticed any problems.
I believe that the shaking was caused by the servos not being refreshed approximately every 20ms due to the length of the program. I have generally seen the PAUSE 20 in much smaller BOE/BOEBOT programs that need to extend the time before refreshing the servos.
I believe that the PAUSE in the ps2rov4 program needs to be somewhere between 0 and 20 ms. Once I have the program the way I want it, I plan to vary the PAUSE value until the servos start to shake, then reduce the PAUSE value slightly. Of course, the easy way out is to employ a servo controller and not have to worry about the servo timing.
Also a note on color coding in the IDE. The IDE has a list of items to color code. There is no direct connection between the compiler and the IDE color coding. Some newer commands/constants do not color code because I haven’t added them to the list in the IDE. This has no effect on whether the the commands/constants work in the compiler.