element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum PSOC 4 Ball and Beam Control System, identification toolbox.
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Cypress Kits to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 33 replies
  • Answers 2 answers
  • Subscribers 28 subscribers
  • Views 4249 views
  • Users 0 members are here
  • psoc4
  • ballandbeam
  • identification
  • controlsystem
  • uart
  • pid
Related

PSOC 4 Ball and Beam Control System, identification toolbox.

juanes.pazj
juanes.pazj over 10 years ago

Short Review:

I have been working on this model for a while now, I was having some trouble with the sensor data but all of that is good now,

Here is how the system works every command is fed through the UART interface as well as data read from sensors or input data.

I managed to control angle only (motor position) although I am not very happy with it is somewhat unstable...

The trouble I am facing is controlling the ball position, the simpler control system I could come up was a cascade PID, the problem is I cant get both plants right for simulation Voltage-Angle and Angle-Position, I wanted to get them with identification toolbox in matlab (I have a transfer function for the angle-position plant it is :.

Since the motor was originally scrap from a printer I cant really get its parameters on a datasheet I know it is a Jhonson Motor, 36mm diameter 56mm length, 3mm shaft there are this numbers printed on it I can't seem to find any relation to a motor model. 65791, c5324-60024, 392361

image

image

 

I am not sure if the following procedure should have been the way to go for identification.

I made a Matlab Script that would read a word of data sent by the psoc through UART, in this format "a#p#t#x#f" so I get current angle, motor power (voltage%), current position, and time.

working with the time vector I managed to extract an average sampling time of 0.005s,

I had to create a PRBS signal to command the motor so I did it internally with two alternate power settings that are outputed on a random time (The plot doesnt make it a square wave but all the points are on +18 or -18.)

image

image

After this I went into Ident toolbox

after removing Means, trends and filtering and separating the data for evaluation and validation, I got a 97% fit with a box Jenkins (1 1 3 3 0) which should make a reliable model for simulation but If I used the PID parameters on the PSOC It would diverge every time I cant seem to find a solution.

 

I appreciate your help,

some questions..

the embedded system (PSOC) is very fast (the actual sampling time is 0.004s approximately, should I slow it down for the control system to work?? it Doesn't seem right.

All the theory says the PRBS signal should be 1,-1 signal How do I know if the PRBS signal's amplitude and width is good enough for identification??

 

I would like to try other control methods (non-linear) (State space) but I cant seem to get the models from identification.

 

I am not sure if the files are of any use without the model.. If you want to see them let me know.

Attachments:
RBBv2.cywrk.zip
  • Sign in to reply
  • Cancel

Top Replies

  • DAB
    DAB over 10 years ago +1
    Hi Juan, You are probably experiencing data lag time. When you try to correct something dynamic by using a measured position, you have to account for the movement of the object while you are calculating…
  • michaelkellett
    michaelkellett over 10 years ago in reply to juanes.pazj +1 suggested
    Do you have Simulink - if so you can model you controller and the system and the delays in the PSOC - this might be the quickest way to develop an algorithm/controller that works. MK
  • DAB
    DAB over 10 years ago +1
    Juan, I just remembered that the PSOC has an analog comparator as part of its programmable hardware. You can use that to provide near instantaneous correction for the balance circuitry. DAB
Parents
  • DAB
    0 DAB over 10 years ago

    Hi Juan,

     

    You are probably experiencing data lag time.

    When you try to correct something dynamic by using a measured position, you have to account for the movement of the object while you are calculating your next change.

    Essentially the small time error keeps adding until your system is just too far out of balance to work.

     

    Take a look at your rate of change data.  You can also try running a predictive model that makes the adjustment for where the ball will be instead of where it was.

     

    One trick I learned was to double the correction value off the measurement.  It is a crude approach, but if you have a well behaved system it can keep you out of the too late correction problem.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • juanes.pazj
    0 juanes.pazj over 10 years ago in reply to DAB

    Hi DAB,

    I have been trying to work arround this problem I made a predictor of the ball position using the physical equation in discrete form, in that way the measured point gets in a previous state, and with that and some angle info I estimate the current position,

    but I think a bigger issue is the comunication to the PC the UART on the PSOC is able to reach 1Msps but the windows setup only allows 120ksps I managed to get an average sampling rate of 0.0036s

    can it be that the processor is not fast enough for the job? I have a Psoc 5 board I was working on making the same program for it but it will have to change a lot should I go for it??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • DAB
    0 DAB over 10 years ago in reply to juanes.pazj

    I do not know.

    You can work it out by calculating how fast the ball moves within your sampling/correction calculation time.

    I think the actual processor is fast enough, but you might need to go to assembly language programming to get the response you need.

    If you are off loading the decision software to your PC and then relying on a serial link to run the messages, that is probably not going to work.

     

    Think about implementing a state machine within the Psoc 5 using an interrupt driven algorithm.  That change might buy you enough time to get your correction loop working in real time.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • DAB
    0 DAB over 10 years ago in reply to juanes.pazj

    I do not know.

    You can work it out by calculating how fast the ball moves within your sampling/correction calculation time.

    I think the actual processor is fast enough, but you might need to go to assembly language programming to get the response you need.

    If you are off loading the decision software to your PC and then relying on a serial link to run the messages, that is probably not going to work.

     

    Think about implementing a state machine within the Psoc 5 using an interrupt driven algorithm.  That change might buy you enough time to get your correction loop working in real time.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube