Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem with digital Potentionmeter controling a 555 Timer

Status
Not open for further replies.

anilson1

New Member
hi,

I am trying to build a simple project which I use a "PIC16F88" communicating through (SPI) with a digital potentiometer DS1267-10 to control the oscillation of a timer 555

Here is the code:

C:
   unsigned char bou[9];
  
void sendDATA()
{
   unsigned char counter = 0;     //Declare and initialize the counter
  
   RB3_bit = 1;                   //Initiate communication through RST
   Delay_us(50);

   while(counter<9)
   {
         if(RB4_bit == 0)
         {
            counter = counter + 1;   //counting pulse on the low
            RB2_bit = bou[counter];  //Send Data
            Delay_us(30);
         }

      RB4_bit = ~ RB4_bit;        //toggle the clock
      Delay_us(50);                //Duty cycle
   }
  
   RB4_bit = 0;
   RB3_bit = 0;                   //Stop communication through RST
}


void main(){

   ANSEL = 0;           // pins are configured as digital I/O

   TRISA = 0xFF;           // set PORTA direction to be input
   TRISB = 0x00;           // set PORTB direction to be output

   PORTB = 0;

   do{
        if(RA2_bit == 0)
        {
          bou[0]=1;
          bou[1]=1;
          bou[2]=1;
          bou[3]=0;
          bou[4]=1;
          bou[5]=0;
          bou[6]=1;
          bou[7]=1;
          bou[8]=0;
        
          sendDATA();
        }

        if(RA3_bit == 0)
        {
          bou[0]=0;
          bou[1]=0;
          bou[2]=1;
          bou[3]=0;
          bou[4]=0;
          bou[5]=1;
          bou[6]=0;
          bou[7]=0;
          bou[8]=0;
        
          sendDATA();
        }
   }while(1);
}


The problem is: the oscillator only oscillates at one frequency, by pressing the buttons it does not chance the oscillation speed. Not sure if the problem is on the circuit or on the code. Any idea?
 

Attachments

  • digitalpotentiometer.jpg
    digitalpotentiometer.jpg
    47.1 KB · Views: 352
Last edited by a moderator:
You're using only the H0,L0,H1,L1 pins of the dual pot. The resistance between those is fixed. You need to use a wiper pin (W0 and/or W1).
 
Your code only has 8 bits.... There should be 17 bits SB, W1bits, W2bits..

I assume you are trying to use stacked... You need to redraw your circuit as well..

Here is the code for single wiper..
C:
unsigned char bou[17];

void sendDATA()
{
  unsigned char counter = 0;  //Declare and initialize the counter

  RB3_bit = 1;  //Initiate communication through RST
  Delay_us(50);

  while(counter<17)
  {
  if(RB4_bit == 0)
  {
  counter = counter + 1;  //counting pulse on the low
  RB2_bit = bou[counter];  //Send Data
  Delay_us(30);
  }

  RB4_bit = ~ RB4_bit;  //toggle the clock
  Delay_us(50);  //Duty cycle
  }

  RB4_bit = 0;
  RB3_bit = 0;  //Stop communication through RST
}


void main(){

  ANSEL = 0;  // pins are configured as digital I/O

  TRISA = 0xFF;  // set PORTA direction to be input
  TRISB = 0x00;  // set PORTB direction to be output

  PORTB = 0;

  do{
  if(RA2_bit == 0)
  {
  bou[0]=0;
  bou[1]=1;
  bou[2]=1;
  bou[3]=1;
  bou[4]=1;
  bou[5]=1;
  bou[6]=0;
  bou[7]=0;
  bou[8]=0;
  bou[9]=0;
  bou[10]=0;
  bou[11]=0;
  bou[12]=0;
  bou[13]=0;
  bou[14]=0;
  bou[15]=0;
  bou[16]=0;

  sendDATA();
  }

  if(RA3_bit == 0)
  {
  bou[0]=0;
  bou[1]=1;
  bou[2]=1;
  bou[3]=0;
  bou[4]=0;
  bou[5]=0;
  bou[6]=0;
  bou[7]=0;
  bou[8]=0;
  bou[9]=0;
  bou[10]=0;
  bou[11]=0;
  bou[12]=0;
  bou[13]=0;
  bou[14]=0;
  bou[15]=0;
  bou[16]=0;

  sendDATA();
  }
  }while(1);
}
And the circuit.... NOTE 555 ouput needs to go to the top of the wiper as you are trying to keep a 50% duty cycle..

upload_2016-3-27_12-7-30.png
 
Last edited:
Your code only has 8 bits.... There should be 17 bits SB, W1bits, W2bits..

I assume you are trying to use stacked... You need to redraw your circuit as well..

Here is the code for single wiper..
C:
unsigned char bou[17];

void sendDATA()
{
  unsigned char counter = 0;  //Declare and initialize the counter

  RB3_bit = 1;  //Initiate communication through RST
  Delay_us(50);

  while(counter<17)
  {
  if(RB4_bit == 0)
  {
  counter = counter + 1;  //counting pulse on the low
  RB2_bit = bou[counter];  //Send Data
  Delay_us(30);
  }

  RB4_bit = ~ RB4_bit;  //toggle the clock
  Delay_us(50);  //Duty cycle
  }

  RB4_bit = 0;
  RB3_bit = 0;  //Stop communication through RST
}


void main(){

  ANSEL = 0;  // pins are configured as digital I/O

  TRISA = 0xFF;  // set PORTA direction to be input
  TRISB = 0x00;  // set PORTB direction to be output

  PORTB = 0;

  do{
  if(RA2_bit == 0)
  {
  bou[0]=0;
  bou[1]=1;
  bou[2]=1;
  bou[3]=1;
  bou[4]=1;
  bou[5]=1;
  bou[6]=0;
  bou[7]=0;
  bou[8]=0;
  bou[9]=0;
  bou[10]=0;
  bou[11]=0;
  bou[12]=0;
  bou[13]=0;
  bou[14]=0;
  bou[15]=0;
  bou[16]=0;

  sendDATA();
  }

  if(RA3_bit == 0)
  {
  bou[0]=0;
  bou[1]=1;
  bou[2]=1;
  bou[3]=0;
  bou[4]=0;
  bou[5]=0;
  bou[6]=0;
  bou[7]=0;
  bou[8]=0;
  bou[9]=0;
  bou[10]=0;
  bou[11]=0;
  bou[12]=0;
  bou[13]=0;
  bou[14]=0;
  bou[15]=0;
  bou[16]=0;

  sendDATA();
  }
  }while(1);
}
And the circuit.... NOTE 555 ouput needs to go to the top of the wiper as you are trying to keep a 5% duty cycle..

View attachment 98530

And that is the way a schematic should look. Ian, I don't use the PIC parts, but couldn't he just use the on-board PWM, and not need the digital pot, or 555?
 
but couldn't he just use the on-board PWM,
Not even that.... Just a bit banged output with variable delays.... Any pic would do it!! But I think this is an exercise..
 
Not even that.... Just a bit banged output with variable delays.... Any pic would do it!! But I think this is an exercise..
Yeah, you are probably right:)
 
just use the on-board PWM, and not need the digital pot, or 555?
Just a bit banged output with variable delays.... Any pic would do it

I do agree, it is a curious thing to do, using a microcontroller to set the frequency of a 555.
However, as a didactic exercise there are a lot of useful things to learn while doing this.

JimB
 
It actually sounds like it should be a little fun.
 
Hi guys,

Thank you all for your input and help.

True, this is just an exercise eventually I will remove the timer 555 and connect the pic and digital pot to a motor controller which is controlled by a variable resistor. The timer is just a way to see how the resistance changes, main focus is on the digital pot using a microprocessor (pic).

I forgot to mention the configuration of the digital pot DS-1267-10 is stack, which puts in series the two resistances inside the chip and the output is on the Sout (pin 13) instead of using the W0 or W1. The datasheet is not very clear but I think it says that for stack configuration it uses 9 bits of resolution.


upload_2016-3-28_0-13-39.png
 

Attachments

  • DS1267_datasheet.pdf
    312.5 KB · Views: 317
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top