• Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Interfase trouble with the raspberry pi 3 (Analog output)

    Scheduled Pinned Locked Moved Unipi 1 - First Generation
    3 Posts 2 Posters 2.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jelle
      last edited by

      Hello,

      I am having trouble with the analog output. I did supply the PWM signal at 400Hz from GPIO18. This PWM signal was measured to make sure that it was there and I tried differed duty cycles. Is there something else that I am missing. Should the jumper wires be in a specific setting or maybe something else?

      1 Reply Last reply
      Reply Quote 0
      • Martin KudláčekM
        Martin Kudláček
        last edited by

        Hello @Jelle,
        can you please share how exactly did you proceed with setting up the PWM signal?

        Thanks,
        Martin

        1 Reply Last reply
        Reply Quote 0
        • J
          Jelle
          last edited by

          I use the wiringPi library so to run this code you should install wiringPi

          #include <stdio.h>
          #include <unistd.h>
          #include <stdint.h>
          
          #include "wiringPi.h"
          
          void gpioSetupCostum()
          {
          
            printf("gpioSetup has started\n");
            wiringPiSetupGpio ();
            usleep(1000);
            printf("wiringPiSetupGpio was a succes\n");
          
            pinMode(18, PWM_OUTPUT);
            usleep(1000);
            printf("pinMode was a succes\n");
          
            pwmSetMode(PWM_MODE_MS);
            usleep(1000);
            printf("pwmSetMode was a succes\n");
          
            pwmSetRange(1024);
            usleep(1000);
            printf("pwmSetRange was a succes\n");
          
            pwmSetClock(47);
            usleep(1000);
            printf("pwmSetClock was a succes\n");
            
          }
          
          void gpioClose()
          {
            pwmSetMode(PWM_MODE_BAL);
            usleep(1000);
            pinMode(18, INPUT);
            usleep(1000);
          }
          
          
          int main()
          {
            int GPIOCounter, SampleCounter;
            double PWM[11]={0, 1 , 2 , 3, 4, 5, 6, 7, 8, 9, 10};
            const int len = 11;	
            int AmountOfSamples = 200;  
            printf("Start setup\n");
            gpioSetupCostum();
            printf("Finish setup\n");
            
            printf("Start reading input ports\n");
            for(SampleCounter =1; SampleCounter <= AmountOfSamples; SampleCounter++){
              printf("Sample = %d\n", SampleCounter);
          	for(GPIOCounter = 0; GPIOCounter < len; GPIOCounter++){
          	  printf("PWM input = %.1f\n", PWM[GPIOCounter]);
          	  pwmWrite(18, (int)((PWM[GPIOCounter] * 1024)/10));
                usleep(1000000);
              }	
            }	
            
            gpioClose();
          }
          
          1 Reply Last reply
          Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post