API integration of PID controller

Applications, development tools, FPGA, C, WEB
Post Reply
JackTheRippchen
Posts: 12
Joined: Tue Sep 26, 2017 10:55 am

API integration of PID controller

Post by JackTheRippchen » Mon Oct 16, 2017 4:12 pm

Hi,
I'm wondering whether anybody has added the PID controller to the API yet. (Reinventing the wheel is waste of time, imho.)

My final goal is to modify the PID-oscilloscope-web-app. I'd like to step the setpoint of e.g. PID11 and capture the step answer by single trigger.
At the moment, this is too difficult for me. Therefore, I prefer going little steps and try to implement this in C without any web GUI. Hence, I need to control by API.

JackTheRippchen
Posts: 12
Joined: Tue Sep 26, 2017 10:55 am

Re: API integration of PID controller

Post by JackTheRippchen » Tue Oct 17, 2017 3:58 pm

Referring to the existing API files on GitHub and this register map, I'm trying to build my own pid.c/pid.h files.

current conception of pid.h:

Code: Select all

#ifndef __PID_H
#define __PID_H

#include <stdint.h>

#include "redpitaya/rp.h"

#define PID_COUNT 4
#define ADC_COUNT_MAX 8191
#define ADC_COUNT_MIN -8192

// Base Generate address
#define PID_BASE_ADDR      0x00300000
#define PID_BASE_SIZE      0x4C

typedef struct pid_control_s {
	unsigned int PID11_IntegratorReset	:1;
	unsigned int PID12_IntegratorReset	:1;
	unsigned int PID21_IntegratorReset	:1;
	unsigned int PID22_IntegratorReset	:1;
	unsigned int 						:28;
    unsigned int PID11_SP				:14;
    unsigned int 						:18;
    unsigned int PID11_Kp				:14;
    unsigned int 						:18;
    unsigned int PID11_Ki				:14;
    unsigned int 						:18;
    unsigned int PID11_Kd				:14;
    unsigned int 						:18;	
    unsigned int PID12_SP				:14;
    unsigned int 						:18;
    unsigned int PID12_Kp				:14;
    unsigned int 						:18;
    unsigned int PID12_Ki				:14;
    unsigned int 						:18;
    unsigned int PID12_Kd				:14;
    unsigned int 						:18;
    unsigned int PID21_SP				:14;
    unsigned int 						:18;
    unsigned int PID21_Kp				:14;
    unsigned int 						:18;
    unsigned int PID21_Ki				:14;
    unsigned int 						:18;
    unsigned int PID21_Kd				:14;
    unsigned int 						:18;
    unsigned int PID22_SP				:14;
    unsigned int 						:18;
    unsigned int PID22_Kp				:14;
    unsigned int 						:18;
    unsigned int PID22_Ki				:14;
    unsigned int 						:18;
    unsigned int PID22_Kd				:14;
    unsigned int 						:18;	
} pid_control_t;

int pid_Init();
int pid_Release();

int pidEnableIntReset(rp_pid_t pid);
int pidDisableIntReset(rp_pid_t pid);
int pidSetParamSP(rp_pid_t pid, float value);
int pidSetParamKP(rp_pid_t pid, float value);
int pidSetParamKI(rp_pid_t pid, float value);
int pidSetParamKD(rp_pid_t pid, float value);

#endif //__PID_H
I don't understand why "PID11 set point" offset is 0x10 (register map page 13), while offset of e.g. "Ch A amplitude scale and offset" is 0x4 (register map page 10). In both cases, 32 bit (= 4 Byte) are described before. :?:

Furthermore, all modules start at address 0x40[x]00000 (register map page 3). In e.g. generate.h, the base address is 0x00200000 instead of 0x40200000. :?:

lazyoracle
Posts: 2
Joined: Tue Aug 21, 2018 8:11 am

Re: API integration of PID controller

Post by lazyoracle » Wed Oct 10, 2018 5:02 pm

Hey. Did you manage to access the PID blocks on the FPGA using the C API? I would be happy to collaborate if you are still working on this.

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 23 guests