2 Touch 4 Function Advice Needed

Hansen

Member
all this base on PICAXE 08M2

C.1 should have 2 functions on and add power
C.4 must hvae 2 Off functions and sub ​​power

On and Off function must change C.0

power change is C.2 nogle PWMOUT 4 forskældig Level

press C.1 if C.0 = 0 let C.0 = 1
if it's on the add power level

Tryp in C.4 if C.0 C.0 let = 1 = 1
If it is on the sub power level

there are some who can give me a code example
to register & program structure
 

nick12ab

Senior Member
Sorry, but I don't understand what you're on about.

But it seems that you are controlling power to something but what are you controlling and why? What is the required power level?
 

papaof2

Senior Member
Is that what you want?

If device is off, touching C.1 turns on C.0. If device is on, touching C.1 increases power to C.0.

If device is on, touching C.4 reduces power to C.0 and eventually turns C.0 off.

This type of power control requires using PWM.

1. Is C.0 capable of doing PWM?

2. What device are you trying to control? You can control a single LED via a PICAXE pin, but you will need an appropriate driver to control a motor, an incandescent bulb or a heating element.

John
 

nick12ab

Senior Member
This type of power control requires using PWM.

1. Is C.0 capable of doing PWM?
C.0 doesn't have PWM, but it has a DAC so with the voltage follower op-amp and other components advised in Picaxe Manual 2 you might get lucky and be able to dim an LED with it but my experience with the DAC on the 18M2 last year was horrible but that was using a transistor as well - this gave about six LED brightness settings.
 

Hansen

Member
C.O is simple ON / OFF function to turn off power to the PWM power driver source

C.2 is 4 level PWM signal at 10Khz to the driver on the LED system

here some will say why not just ture off C.2 to shut off PWM power system, it CAN'T be don. it why I use the C.0 with Power FET
 

eclectic

Moderator
1. @Hansen.
Please post in your native language (Danish?)
Please post your circuit diagram / Schematic


2. A possibility

Program starts with NO output.

Code:
C.0  = Indicator LED

C.1 = Touch and start.
 Switch on C.0
 Then, increase Pwmout duty

C.2 =  Pwmout

C.4 = Decrease Pwmout duty.
  When duty = 0,   Switch off C.0
e
 

Hansen

Member
ok

for start

press C1 it ture on pwm level 1
then
press C1(1 sec+) again pwm goto level 2
then
Press C1(1 sec+) again pwm goto level 3
then
Press C4(1 sec+) now pwm goto level 2
then if
Press C4 less than 1 sec PWN turn off (c.0) and PWN base level set to 0
 

hippy

Ex-Staff (retired)
The way I'd approach this is as a Finite State Machine (FSM) monitoring 'button pushes' ( I'd only update that to being touch inputs later ) which can then raise 'events' -

1) On/Up pushed for less than a second and released
2) On/Up pushed and held for a second
3) Off/Down pushed for less than a second and released
4) Off/Down pushed and held for a second

1 and 3 have to act on release ( that's implicit ). 2 and 4 can act while still held ( which also opens the door to auto-repeat if continually held ) or can delay and act on release.

Those events I'd feed as triggers into a second FSM-like piece of code which sets the PWM and LED control.

With 08M2 multi-tasking it would likely fit well with each FSM as separate tasks. A third task could simply read buttons and feed those as flags ( pushed / released ) into the button handling task, and that task can then be easily modified to use Touch later. In fact it could be an ideal, model multi-tasking application.
 

Attachments

Hansen

Member
The way I'd approach this is as a Finite State Machine (FSM) monitoring 'button pushes' ( I'd only update that to being touch inputs later ) which can then raise 'events' -

1) On/Up pushed for less than a second and released
2) On/Up pushed and held for a second
3) Off/Down pushed for less than a second and released
4) Off/Down pushed and held for a second

1 and 3 have to act on release ( that's implicit ). 2 and 4 can act while still held ( which also opens the door to auto-repeat if continually held ) or can delay and act on release.

Those events I'd feed as triggers into a second FSM-like piece of code which sets the PWM and LED control.

With 08M2 multi-tasking it would likely fit well with each FSM as separate tasks. A third task could simply read buttons and feed those as flags ( pushed / released ) into the button handling task, and that task can then be easily modified to use Touch later. In fact it could be an ideal, model multi-tasking application.
Nice solution
I have not thinking about multitask option this is new for me

make lot off small around the (08m and the 20x2 in the past)
 
Top