element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino Math problem
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 5 replies
  • Subscribers 401 subscribers
  • Views 498 views
  • Users 0 members are here
Related

Arduino Math problem

Former Member
Former Member over 13 years ago

Hi,

 

Currently I using arduino mega for a project which need to apply integration and transfer function.

May I know is there any sample code for these?

I know that I may use discrete method for integration and look up table for transfer function but I have no idea how to start coding.

 

Thanks for the help.

 

 

Regards.

  • Sign in to reply
  • Cancel
Parents
  • michaelkellett
    0 michaelkellett over 13 years ago

    You need to give a lot more detail about your problem - currently the scope addressed by your question is too wide for a simple answer.

     

    Michael Kellett

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 13 years ago in reply to michaelkellett

    I have a system that with the feedback it calculate out the acceleration of the motor, then I need to integrate the acceleration to get its velocity then integrate again to get the position of the motor.

     

    As for the transfer function, I have a potential meter and the output of it need to go through a transfer function 1/(0.5s + 1).

     

     

    Hope this is what you want?

     

     

    Regards

    Chao Hong

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 13 years ago in reply to Former Member

    I'm suprised that you have an acceleration signal, velocity or dispalcement are more common - you will find it very difficult to control displacement from acceleration.

     

    The way to tackle this problem is to do the maths first and write the code afterwards. Once you've got the maths sorted the code is easy.

    I know a few ways to get the maths done -

    find an example  - books - Google etc

    work it out from first principles

    model the system using something like MATLAB/SIMULINK, VISIM, MAPLE SIM etc etc

     

    One problem is that your Arduino, being digital, can't (no matter how clever the maths) avoid the fact that it will process discrete samples from and ADC with finite resolution - in real systems this is often very important and it is often easier to model the effects rather than calculate them.

     

    Let me know if you have access to any of the tools above and please describe your problem a bit more - what are you trying to control and why. ( If it's a one off and money is no object just buy a controller, if you want to make loads of them cheap that's one problem, if its a hobby thing and you just want to make it work - that's another or if you're a student and you have to do it a particular way .............)

     

    Michael Kellett

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 13 years ago in reply to michaelkellett

    Thanks for your patient. I'm a student working on a project of sch.

     

    Mine is like doing an automated rocking chair and I have the fomular and simulink model(done by other) already.

    There is a virtual rocking motion in the system which will always use to compare with the actual position of the chair.

    I'm using a hall sensor to get the position of the chair. Besides, the acceleration, velocity is just generate by the virtual system through internal setting.

     

    Now I have to program with arduino and I stuck with how to implement integration and transfer function in coding.

     

     

     

    Chao Hong

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 13 years ago in reply to michaelkellett

    Thanks for your patient. I'm a student working on a project of sch.

     

    Mine is like doing an automated rocking chair and I have the fomular and simulink model(done by other) already.

    There is a virtual rocking motion in the system which will always use to compare with the actual position of the chair.

    I'm using a hall sensor to get the position of the chair. Besides, the acceleration, velocity is just generate by the virtual system through internal setting.

     

    Now I have to program with arduino and I stuck with how to implement integration and transfer function in coding.

     

     

     

    Chao Hong

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • michaelkellett
    0 michaelkellett over 13 years ago in reply to Former Member

    I don't understand what you mean by "virtual rocking motion in the system which will always use to compare with the actual position of the chair" and "velocity is just generate by the virtual system through internal setting".

     

    Does the hall sensor give you a linear output proportional to the position of the chair or just a pulse. What sensor inputs does the 'virtual system' have. What kind of actuator are you using.

     

    If you have a SIMULINK model you could post it here. You should separate out the controller in the model from the system you are controlling (ie separate the plant and the controller). Then you need to use the SIMULINK tools to make a discrete time and quantised controller. Once you've got that (unless it's mega complicated) it will be easy to see how to code it.

     

    int32_t integrate(int32_t input)

         {

         static int32_t integral = 0;

         integral += input;

         return(integral);

         }

     

    Simple (and almost useless) discrete integrator (1/z) in C. There is no means to reset it (which is why it is (probably) useless).

     

     

     

    Michael Kellett

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
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