Home
BlackLib - User Manual
Contents
1. test gt setPolarity reverse This function sets run state of pwm signal It sets run value to 1 or 0 The input parameter is converted to 1 or O and this value is saved to run file It takes a pwm_value type variable and this variable uses for setting run state It returns true if setting new run state is successful else false test gt setRunState stop This function toggles run state of pwm signal It sets run value to 1 or O by value of current state This new value is saved to run file test gt toggleRunState This function toggles polarity type of pwm signal It sets polarity value to 1 or O by value of current polarity This new value is saved to polarity file test gt tooglePolarity Page 14 23 This function checks run state of pwm signal It calls getRunValue function and evaluates return value It returns false if return value equals to 0 else true if test gt isRunning cout lt lt Pwm signal is running now This function checks polarity state of pwm signal It calls getPolarityValue function and evaluates return value It returns true if return value equals to O else false if test gt isPolarityStraight cout lt lt Pwm signal has straight polarity This function checks polarity state of pwm signal It calls getPolarityValue function and evaluates return value It returns false if return value equals to 0 else true if test gt isPo
2. cout lt lt PWM period value ns lt lt x lt lt endl cout lt lt PWM period value us lt lt x 1000 lt lt endl cout lt lt PWM period value ms lt lt x 1000000 This function returns numeric duty value of pwm signal It calls getDutyValue function for finding out the duty value After do that this duty value is converted to uint32 t type by using strtoimax function It returns uint32 t type duty value uint32 t x test gt getNumericDutyValue cout lt lt PWM duty value ns lt lt x lt lt endl cout lt lt PWM duty value us lt lt x 1000 lt lt endl cout lt lt PWM duty value ms lt lt x 1000000 This function sets percentage value of duty cycle If input parameter is in range from O to 100 this function changes duty value without changing period value For calculating new duty value the current period multiplies by entered percentage and this product subtracts from period After do that this calculated value is saved to duty file It takes a float type variable and this variable uses for setting new percentage value It returns true if setting new value is successful else false float x 41 0 test gt setDutyPercent x Page 12 23 This function sets period value of pwm signal If input parameter is in range from O to 10 or greater than current duty value this function changes period val
3. BlackLib User Manual Beaglebone Black C Library Author Yigit Yuce 22 04 2014 blacklib yigityuce com Page 1 23 CONTENTS 1 2 3 4 5 VANS ISG SV V eet ar eer na a narak ae sm ree 3 EV R a a a baba na arma m AE E RaR EE TEREA SEAN E EREN ERA RR ERR ENEA ERRERA EES 3 INTRODUCTION erorii ara NE AAAA A 3 LUCENE aee A EE E E E 3 LEE 0 TE N Va ame ann aa la SM MARA amala E E E A ERER 4 PEVCE MEP ek e elek 4 elek allak 0 alamam tae det esata tated ie sema ni ARR 4 e 7 A A PEPE PEPE 4 LIS aE E O A A e seta 4 including LIDT ATY ecese ERES 4 SPEA DER ONE anra MY 5 d ADE BY a1 dco g RA ee A E E R 5 D PMV IVD GT IMINO INS aran sadekar OE 6 GE VEL T N ar pron racapsouovecraesovaaarcerscuceaernenacaeserqpeseseacnassqnaneaenasamanencaasamaseneaasnmanencnananaass 7 FunctionsTlhatinteractWithEndUsers 0 8 a ADC Management Functions saab akmadan kema elele bad bek ha k meee eebehwes lu Babul babalmalabaansi 8 b PWMManagementFunctions enez 10 c GPIO Management Functions annenin n n abroad alen 17 Debugging and Error FlagS cccceccseccseceseceeccseceseesecteeeeneeeeceeeeeneeseeeeeeeeeeseteeeteeeeeeteeseeeeeaees 19 a ADC Error Flags and Usage cc csscssscousscscsssccussesesuscoussesesusccussesetestssccussosssssccussesstssceusss 19 D PWM Error Flags and USAC Cs vera saran veee ei ann e ea ag KOD G e a
4. type variable This variable s value can be only low or high low sets pin to logical O state and high value sets pin to logical 1 state An example shown in below is about this function and usage of pin value variable 3 Functions That Interact With End Users a ADC Management Functions This function returns analog input value It reads specified file from path where defined at BlackADC ainPath variable This file holds analog input voltage at milivolt level It returns string type analog input value If file opening fails it returns error message This function returns analog input value It reads specified file from path where defined at BlackADC ainPath variable This file holds analog input voltage at milivolt level It returns integer type analog input value If file opening fails it returns 1 n int x test gt getNumericValue 100 cout lt lt AIN value 0 1V lt lt x lt lt mV Page 8 23 This function returns converted analog input value It gets value by using getNumericValue function and converts this value to volt level according to input parameter It takes a digit_after_point type variable This variable shows conversion level It returns converted analog input value as float 7 float x test gt getParsedValue dap3 cout lt lt AIN at a bcd format lt lt x lt lt Volt This function uses for general debugging It r
5. l nl 20 FN e TOE AN O se 22 BIBUOGRA PHI NERE EE TENE MEME MEMEN N A NE NER ME 23 Page 2 23 1 ABSTRACT This file is prepared for BlackLib Library documentation This document s target group is end users BlackLib Library that is discussed at this document is wrote with C programming language for Beaglebone Black 2 KEYWORDS Beaglebone Black BlackLib C library PWM ADC GPIO 3 INTRODUCTION BlackLib is written with C programming language for Beaglebone Black You can use Beaglebone Black s ADC GPIO and PWM features by dint of this library It can work with Kernel 3 7 and later versions and licensed with LGPL 4 LICENSE BlackLib Library controls Beaglebone Black input and outputs Copyright C 2013 2014 by Yigit YUCE This file is part of BlackLib library BlackLib library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version BlackLib library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this program If not see lt http www gnu org licenses gt For any comment or suggest
6. isPolarityStraight isPolarityReverse setPolarity tooglePolarity gt You can check this flag after call these functions setDutyPercenti setPeriodTimel setSpaceRatioTimel gt setloadRatiolimel After called a function which opens run file After called a function which opens polarity file After called a function which takes numeric variable and uses this variable for make an adjustment Page 21 23 f t fil exportFileErr Sone a errorCoreGPlO After pin exporting process opening error a TEE direction file a directionFileErr errorCoreGPIO After pin direction setting process opening error If you try to initialize GPIO one more time this error will occur Under normal conditions you can initialize gpio only once from BlackGPIO class If read or write errors occur you can check oil this error In addition to these errors if exportErr fea errorGPIO exportErr occurred also this situation shows pin is not exported or unexported by manually after initialization If read or write errors occur you can check this error In addition to these errors if directionErr pin direction error errorGPIO directionErr occurred also this situation shows pin direction changed by manually after initialization value file readin For checking accuracy after readin error process value file writin For checking accuracy after writin writeErr 6 errorGPIO 6 i 6 error process sin value
7. alue is successful else false This function checks value of GPIO pin It calls getValue function and evaluates return value It returns false if return value equals to 0 else true aaa a aaa a a uP a SU SS SP a dl l if test gt isHigh cout lt lt GPIO value is 1 1 Page 17 23 This function toggles value of gpio pin If pin type is output this function sets pin value to 1 or 0 by value of current state This new value is saved to value file VVE VEE EE EE tocar test gt toggleValue This function uses for general debugging It returns true if any error occur else false B l if test gt fail cout lt lt Error General error occurred 1 This function uses for specific debugging You can use this after call BlackGPIO member functions in your code It takes a flags type variable and this variable uses for finding out status of selected error It returns value of selected error perna l if test gt fail exportErr cout lt lt Error Pin didn t export Page 18 23 4 Debugging and Error Flags Error flags are controlled after called member functions The objectives of flags are problem tracking If problems occur when functions are running the flags record these problems Error types vary by function s task For this reason you should know which flag will be controlled after which function ran For instance if y
8. ckPWM EHRPWM1A BlackPWM test P9 14 or BlackPWM test EHRPWMIA Oe a Oe The pwm signal must start generating to get from PWM outputs v pwm value setRunState function is wrote to start or stop generating signal 2 stop This function takes one parameter and it can be pwm value type variable This variable s value can be stop or run run starts generating signal and stop terminates signal An example shown in below is about this function and usage of owm value variable Page 6 23 c GPIO Definitions pin name is sub option that uses to define which GPIO pin will select You can select which GPIO pin of Beaglebone Black will use by dint of this sub option Beaglebone Black has two GPIO ports and each of these ports have 46 pins These port s names are P8 and P9 But entire pins can t use directly by end user Some of these pins use for Beaglebone Black s own features such as HDMI output SD card LCD screen etc Hence you should make decision which pins or features will use before start your project Even sometimes you may be obliged to load Device Tree for using some pins General purpose pins can use two types These types can be input or output Input pins use for reading digital data from outside output pins use for generating digital data to outside world Digital data can be logical O or 1 Pin type selection can perform with
9. er initialization of BlackPWM loading error class pwm test For checking PWM device driver after pwmrTestErr name finding errorCorePWM initialization of BlackPWM class and device error tree loading processes If you try to initialize pwm one more time m Initialization this error will occur Under normal initializeErr errorCorePWM ei i error conditions you can initialize pwm only once from BlackPWM class gt eriod file After called a function which opens period periodFileErr P errorPWM 1 j j opening error file duty file After called a function which opens dut dutyFileErr i y errorP WM 2 p i opening error file t You can check this flag after call these functions getValue getNumericValue getPeriodValue getNumericPeriodValue setPeriodTime setSpaceRatioTime setLoadRatioTime can check this flag after call these functions getValue getNumericValue getDutyValue getNumericDutyValue setDutyPercent setPeriodTime setSpaceRatioTime setLoadRatioTime NA Yo y NG NONGA N NG NAN O N NN NA No Nr Page 20 23 run file opening error runFileErr polarity file opening error polarityFileErr entered value outOfRangeErr range error errorPWM errorPWM errorPWM t You can check this flag after call these functions getRunValue isRunning setRunState toggleRunState You can check this flag after call these functions getPolarityValue
10. eturns true if any error occur else false PRS SS likeme kkk mealini alinin ii l if test gt fail cout lt lt Error General error occurred This function uses for specific debugging You can use this after call BlackADC member functions in your code It takes a flags type variable and it is used for finding out status of selected error It returns value of selected error m iy aura aaa aR uu vu vu e ue RES SCR COE eu Rac a ag aca aa ak ak a a a a a a ka a a ad aaa aa a aa a aa oa ao os l if test gt fail ReadFrr cout lt lt Error Analog input file read error Page 9 23 b PWM Management Functions This function returns percentage value of duty cycle It calls getNumericPeriodValue and getNumericDutyValue functions for finding out the period and duty values of pwm After do that it calculates percentage value It returns string type percentage value This function returns period value of pwm signal It reads specified file from path where defined at BlackPWM periodPath variable This file holds pwm period value at nanosecond ns level It returns string type period value If file opening fails it returns error message This function returns duty value of pwm signal It reads specified file from path where defined at BlackPWM dutyPath variable This file holds pwm duty value at nanosecond ns level It returns string type duty value If file opening fails it
11. ion please contact the creator of BlackLib Library at ygtyce gmail com Page 3 23 5 NEED TO KNOW 1 Device Tree The Device Tree is a data structure for describing hardware Rather than coding every detail of a device into an operating system a lot of hardware can be described in a data structure These structures passed to the operating system at boot time The structures can hold any kind of data Device tree data must be laid out in a structure that operating systems can understand A bindings is a description of how a device is described in the device tree 1 2 C 11 C 11 formerly known as C 0x is the most recent version of the standard of the C programming language 2 Functions which is wrote with C 0x standard can t use without add C 0x flag to compiler For this reason when compiling stage you must add to this flag Compiling C 11 with g is explained at this link 3 or if you use eclipse for development Eclipse CDT C 11 C 0x support is explained at this link 4 You have to do these steps to compile your code which uses this library 6 USAGE 1 Including Library You must do this for using the library Copy the BlackLib directory to your code s directory Add this code to top of your code include Blacklib Blacklib h Page 4 23 2 Special Definitions After choose Beaglebone Black s which feature to use you must choose the features sub options when approp
12. ith g Stack Overflow Stack Overflow 2012 Online Available http stackoverflow com questions 10363646 compiling c11 with g 4 Eclipse CDT C 11 C 0x support Stack Overflow Stack Overflow 2012 Online Available http stackoverflow com questions 9131763 eclipse cdt c11 cOx support Page 23 23
13. larityReverse cout lt lt Pwm signal has reverse polarity Page 15 23 This function uses for general debugging It returns true if any error occur else false re ee Ree AA Ak A kd kk ke eek edt kt ek Akh Al EA l if test gt fail cout lt lt Error General error occurred This function uses for specific debugging You can use this after call BlackPWM member functions in your code It takes a flags type variable and this variable uses for finding out status of selected error It returns value of selected error M eS NR TOE e a ola EE A EE EE EE EE EE IE ETE EE IE lekeler EE IE EEE EEE l if test gt fail outOfRangeErr cout lt lt Error Pwm entered value is out of range Page 16 23 c GPIO Management Functions This function returns value of GPIO pin It checks pin ready state by calling isReady function If pin is ready it reads specified file from path where defined at BlackGPIO valuePath variable This file holds gpio pin value It returns string type gpio pin value If file opening fails or pin isn t ready it returns error message This function sets value of GPIO pin If pin type is output and pin is ready it sets pin value to 1 or 0 The input parameter is converted to 1 or O and this value is saved to value file It takes a gpio_value type variable and this variable uses for setting value of pin It returns true if setting new v
14. ou check read error flag after calling function that executes writing process this control result will be incorrect Using flags which belong to errorCore or errorCore ADC PWM GPIO data structures are not necessary for end user These flags are made for developers who want to write code on cores of library capemgr name Anywhere in your code before using comgrErr findi errorCore inding error capemgr name ocp name Anywhere in your code before using oc ocpErr errorCore y y oor finding error name device tree For checking device tree loading process dtErr errorCoreADC Seale a loading error erate after initialization of BlackADC class h ber name For checking ADC device driver after helperErr p errorCoreADC initialization of BlackADC class and device finding error ji tree loading process fil i For checki f i ile reading or checking accuracy a terreading analog error value process t You can check this flag after call these functions getValue getNumericValue getParsedValue Page 19 23 capemgr name Anywhere in your code before using comgrErr ae errorCore finding error capemgr name ocp name Anywhere i de bef i apiki p e ywhere in your code before using ocp finding error name device tree For checking device tree loading process dtErr errorCorePWM Wi gn a tar loading error aram after initialization of BlackPWM class iie For checking second device tree loading dtSubSystemErr errorCorePWM process aft
15. pin type option When you initialize BlackGPIO class into your code two parameters are expected from you These are pin number and pin type selections These parameters are pin name and pin type type variables Usages of these options are like below BlackGPIO test new BlackGPIO GPIO 30 input OI BlackGPIO test new BlackGPIO GPIO 60 output a a a V pin name GPIO 30 GPIO 60 GPIO 31 GPIO 40 GPIO 48 GPIO 51 GPIO 4 GPIO 5 GPIO 3 GPIO 2 GPIO 49 GPIO 15 GPIO 117 GPIO 14 GPIO 125 GPIO 123 GPIO 121 GPIO_122 GPIO 120 GPIO 20 GPIO 7 GPIO 38 GPIO_39 GPIO 34 GPIO 35 GPIO 66 GPIO 67 GPIO 69 GPIO 68 GPIO 45 GPIO 44 GPIO 23 BlackGPIO test GPIO 30 input GE BlackGPIO test GPIO 60 output Page 7 23 GPIO 26 GPIO 47 GPIO 46 GPIO 27 GPIO 65 GPIO 22 GPIO 63 GPIO 62 GPIO 37 GPIO 36 GPIO 33 GPIO 32 GPIO 61 GPIO 86 GPIO 88 GPIO 87 GPIO 89 GPIO 10 GPIO 11 GPIO 9 GPIO 81 GPIO 8 GPIO 80 GPIO 78 GPIO 79 GPIO 76 GPIO 77 GPIO 74 GPIO 75 GPIO 72 GPIO 73 GPIO 70 GPIO 71 Gpio pin has to be output type for setting a new pin YO pintwe YG pin wlue value Setting GPIO pin s direction is performed when a input a low initializing BlackGPIO class If pin type is arranged to input lk bigh type at this stage user can t change this pin s value later setValue function is wrote for setting pin value This function takes a pin value
16. returns error message Page 10 23 This function returns run value of pwm signal It reads specified file from path where defined at BlackPWM runPath variable This file holds pwm run value It only can be 1 or 0 It returns string type run value If file opening fails it returns error message cout lt lt PWM run value lt lt test gt getRunValue This function returns polarity value of pwm signal It reads specified file from path where defined at BlackPWM polarityPath variable This file holds pwm polarity value It only can be 1 or 0 It returns string type polarity value If file opening fails it returns error message cout lt lt PWM polarity value lt lt test gt getPolarityValue This function returns numeric percentage value of duty cycle lt calls getNumericPeriodValue and getNumericDutyValue functions for finding out the period and duty values of pwm After do that it calculates percentage value It returns float type percentage value of duty cycle float x test gt getNumericValue cout lt lt PWM percentage value lt lt x Page 11 23 This function returns numeric period value of pwm signal It calls getPeriodValue function for finding out the period value After do that this period value is converted to uint32_t type by using strtoimax function It returns uint32 t type period value uint32 t x test gt getNumericPeriodValue
17. riate In our case these options can choose with special definitions Special definitions are unique for each feature and these names differ from the others The names defined with enumeration property ANC TNyafinitiana ADC Definitions AS nam adc name definition is sub option which you can use when you adc name want read data from Beaglebone Black s analog inputs You can select 2 which AINx input will use for read analog value by dint of this sub a AINI apron a AIN2 a ANS Beaglebone Black has 8 ADCs even though one of these a AINA allocated for Beaglebone Black and disallowed to mount external analog a AINS device Therefore you can read only 7 analog inputs on Beaglebone Black a AING ADC name selection is the one and only expected parameter when you initialize the BlackADC class in your code This parameter can be adc name variable The usage of adc_name option is like below BlackADC test new BlackADC AINO When reading ADC value is read at mV millivolt level So ne ii igit_ oint generally you must scale this millivolt level value For this reason digit_after_p getParsedValue function is wrote in the library This function j j 37 dap takes one parameter and it can be digit after point type j p gi o dp variable You can define how many digits will exist after point at converted value with this variable An example shown in belo
18. tercne If you try to write value to input type pin forcingErr Sena errorGPIO this error will occur You can check this error after writing process t You can check this flag after call these functions getValue gt isHighl toggleValue setValue You can check this flag after call these functions getValue gt isHighl toggleValue setValuej gt You can check this flag after call these functions y getValue gt isHigh toggleValue You can check this flag after call these functions setValuej gt You can check this flag after call these functions setValue initializeErr Initialization error errorCoreGPIO Page 22 23 Some of GPIO flags can be set at the same time When these times you must evaluate these flags together for understand the actual reason of error Error tracking algorithm sets flags properly by taking occurred problems into consideration For this reason some of these combinations have special meanings This situation is valid for GPIO flags only GpioFlagsUsageTable document which exists in document files directory is prepared for these combinations usage Please visit our website for detailed technical documents blacklib yigityuce com 7 BIBLIOGRAPHY 1 Device Tree Online Available http www devicetree org Main Page 2 C 11 Wikipedia 2012 Online Available http en wikipedia org wiki C 2B 2B11 3 Compiling C 11 w
19. ue by saving entered value to period file It takes a uint32_t type variable and this variable uses for setting new period value It returns true if setting new value is successful else false uint32 t x 400000000 test gt setPeriodTime x This function sets space time value of pwm signal If input parameter is in range from O to current period value this function changes duty value by saving entered value to duty file It takes a uint32_t type variable and this variable uses for setting new space time It returns true if setting new value is successful else false uint32 t x 400000000 test gt setSpaceRatioTime x This function sets load time value of pwm signal If input parameter is in range from O to current period value this function changes duty value For calculating new duty value the entered value subtracts from the current period value After do that this calculated value is saved to duty file It takes a uint32_t type variable and this variable uses for setting load time It returns true if setting new value is successful else false uint32 t x 400000000 test gt setLoadRatioTime x Page 13 23 This function sets polarity of pwm signal It sets polarity value to 1 or 0 The input parameter is converted to 1 or O and this value is saved to polarity file It takes a pwm_polarity type variable and this variable uses for setting polarity type It returns true if setting new polarity is successful else false
20. w is about this function and usage of digit after point variable float value test gt getParsedValue dap2 Page 5 23 b PWM Definitions 7 al Ml u u B pwm pin name pwm pin name or pwm bus name are sub options which you can use when you want generate PWM signal from Beaglebone ke i Black s PWM outputs You can select which PWM output will use for a P9 14 generating pwm signal by dint of this sub options a P9 16 a PO 21 Beaglebone Black has a lot PWM outputs Available of these 5 P9 22 outputs defined on the side of page These PWM outputs located on P8 z aa 42 and P9 ports You can use PWM outputs with theirs symbolic names beside pwm bus name a EHRPWM2B o EHRPW MZA o EHRPW MTA their pin names These symbolic names defined on the side of page List orders on the lists are same for both In other words P8 13 and EHRPWM2B are same PWM output like P9 42 and ECAPO EHRPWM represents Enhanced High Resolution Pulse Width ekil Modulation and ECAPO represents Enhanced Capture Pulse Width 2 eee eee EHRPWMOA Modulation i o ECAPO Pin or bus name selection is the one and only expected parameter when you initialize the BlackPWM class in your code This parameter can be pwm pin name or pwm bus name variable The usages of these options are like below BlackPWM test new BlackPWM P9 14 or BlackPWM test new Bla
Download Pdf Manuals
Related Search
Related Contents
MANUAL DE INSTALAÇÃO DO AGENTE DE MONITORAMENTO 一 一 積載条件 メカ名 車種名 タイブ 年式 最大積載養サイクル Samsung NX30 دليل المستخدم COACHING d`AP - Feedback d`entretien Whirlpool RM235PXK User's Manual O2Notification User Manual 普通騒音計 TYPE 6236 TYPE 6236 納入仕様書 Copyright © All rights reserved.
Failed to retrieve file