CQ_KIT_Ver1_5
Dependencies: mbed RateLimiter BLDCmotorDriverCQ_KIT_Ver1_5
main.cpp
- Committer:
- avilei
- Date:
- 2016-10-13
- Revision:
- 3:4c71d3475814
- Parent:
- 2:4ae769d0b112
- Child:
- 4:3f63eed73ad1
File content as of revision 3:4c71d3475814:
/* mbed Microcontroller Library * Copyright (c) 2006-2016 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // This example is based on the BLDCmotorDriver motor control library // by the TVZ Mechatronics Team, University of Applied Sciences Zagreb, // Professional Study in Mechatronics: // https://developer.mbed.org/teams/TVZ-Mechatronics-Team/code/BLDCmotorDriver/ #include <stdio.h> #include "mbed.h" #include "RateLimiter.h" #include "SPN7Driver.h" // Pin definitions for X-NUCLEO-IHM070M1 with STM32 Nucleo boards #include "x_nucleo_ihm07m1_targets.h" // Instance of the motor driver SPN7Driver M( P_IN1, P_IN2, P_IN3, // Logic input pins P_EN1, P_EN2, P_EN3, // Enable channel pins P_HALL1, P_HALL2, P_HALL3, // Hall sensors pins P_FAULT // Fault LED ); // Duty cycle value to be used for speed control float dc = 0.0f; int main() { printf("Press 'w' to speed up, 's' to speed down\n\r"); // sampleTime = 1e-3, switchingFrequency = 20e3, rampUpSlope = 1, rampDownSlope = -1 //M.configure(1e-3, 50e3, 0.1f, -0.1f); while(true) { char c = getchar(); if((c == 'w') && (dc < 0.9f)) { dc += 0.1f; M.setDutyCycle(dc); } if((c == 's') && (dc > -0.9f)) { dc -= 0.1f; M.setDutyCycle(dc); } printf("Duty Cycle: %1.2f, Sector: %d\n\r",dc, M.getSector()); } }