Hello Don,

Don>>Dwayne,I thank you but your example is on 4 bits and I'm interested in a calculation routine (if it's possible in basic) for sinewave with resolution of 10 or 12 bits.
I think it's possible to calculate this with math function in PBP.
But I'm not good in math and I need some help.<<

Then expand the resistors (by doubling them) and use more Pins. the principal is the same. You only add more resistors and pins to whatever resolution you want.

You can have port b represent the first 8 bits, and Part of Port A represent the last 2 to 4 bits..... connect up the resistors in the same ladder configuration, and repeat the pattern for 10 to 12 bits, instead of 4 bits in the example.

If you notice, they are only doing a binary count. And you can do that with the port.

Portb=0;
Porta=0;

Loop:
Portb=portb+1;
if(Portb=0000) then Porta.0=Porta+1
if(Porta>3) then Porta=0;
goto Loop:


This is a simplfied 10 bit code.

Dwayne