setfreq affecting Touch sensing

JamesyHutton

New Member
Hi,
I have a very big problem :(
I am making a touch scrollwheel.

For other parts of my code, it is essential to be running the picaxe as fast as possible. (I plan on using the 28x2 running at 64mhz with a crystal as soon as it ships)

For the time being I am using a 14m2 at 32mhz to test the scroll wheel design.

When I write setfreq m32 all my touch values are always 255.

I was expecting this, as it makes sense knowing how cap sensors use pulses to detect the time it takes to charge the electrode and setting the clock speed higher effects the timing. However I am wondering if there is any way to avoid this without having to change the clock speed back to its default every time I run the touch command.

Since I am using a scroll wheel to change the color of an led, going back to the default speed everytime I detect touch will really lag the rest of the code which is already noticeably laggy at 32mhz! (i.e. you can see the "flicker" as the rgb led fades through some colors).

Am I stuck with switching the speed back and forth?

Thanks
 

AllyCat

Senior Member
Hi,

Have you read the relevant pages in Manual 2? For exampe, the following covers your question:

"When possible it is recommended that a ‘touch16’ command with a word
variable is used. This will maintain the highest possible accuracy."


"The clock speed will affect the count rate and so the result will change for each
clock speed. Therefore the touch command must be calibrated at the actual clock
speed in use."


Cheers, Alan.
 

inglewoodpete

Senior Member
Two comments.

From my experience, the touch control in PICs (used in the PICAXE) is not simple to use. However, in the right conditions it can be programmed to work quite well. You need to determine the "normal" average reading and "touch" average reading and set a threshold value somewhere in between. It is VERY important to keep all PWM wiring well away from the Touch wiring and pads.

RGB lights should not need a PICAXE to run at maximum speed to be flicker free. I'm currently using a 20M2 at 8MHz with 3 channels of PWM controlling an RGB LED which is flicker-free. Some form of slew control needs to be incorporated in your software.

Post your code and we'll see if forum members can help.
 
Top