Skip to content

Commit

Permalink
Merging
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jul 1, 2017
2 parents 913d7d6 + f027a8d commit 81bd764
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 198 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.piolibdeps
.clang_complete
.gcc-flags.json
/src/*.gch
2 changes: 1 addition & 1 deletion lib/PID_Bowler
65 changes: 0 additions & 65 deletions src/.travis.yml

This file was deleted.

65 changes: 0 additions & 65 deletions src/.travis0.yml

This file was deleted.

3 changes: 3 additions & 0 deletions src/main.cpp → src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void runPid(){
for (int i=0;i<numberOfPid;i++){
//reset after encoders have been updated a few times
pid[i]->InitilizePidController();
if(pid[i]->GetPIDPosition()>2048){
pid[i]->pidReset(pid[i]->GetPIDPosition()-4095);
}
//pid[i]->ZeroPID();// set the current encoder value to 0
// this should be replaced by calibration routine
pid[i]->SetPIDEnabled( true);// Enable PID to start control
Expand Down
5 changes: 4 additions & 1 deletion src/MyPid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ float PIDimp::resetPosition( float newCenter){
}
void PIDimp::onPidConfigureLocal(){
setPIDConstants(kp,ki,kd);
// pd velocity constants
state.config.V.P=vkp;
state.config.V.D=vkd;
// this will change the sign of the output signal, and will flip between converging and and diverging
state.config.Polarity=true;
state.config.stop=0.5f;// the center value for the servo object
// this is the maximum value that should come in through setOutputLocal
state.config.outputMaximum=0.7f;
// this is the minimum value that should come in through setOutputLocal
state.config.outputMinimum=0.4f;
state.config.outputMinimum=0.3f;
// the smallest increment of change for the output
state.config.outputIncrement=0.0005f;
// the upper and lower hystersis values for where the motor starts moving
Expand Down
4 changes: 3 additions & 1 deletion src/MyPid.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include "AS5050.h"
#include "Servo.h"
#include "RunEvery.h"
#define kp 0.01
#define kp 0.005
#define ki 0
#define kd 0
#define vkp 0.005
#define vkd 0
class PIDimp : public PIDBowler{
public:
// constructor taking in the hardware objects
Expand Down
50 changes: 50 additions & 0 deletions src/checksum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @file checksum.cpp
* @brief Utility Function - Data integrity helpers
* @author sam grove
* @version 1.0
*
* Copyright (c) 2013
*
* 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.
*/

#include "checksum.h"

bool validateChecksum( uint8_t const *pkt, uint32_t const length )
{
uint32_t pos = 0;
uint8_t sum = 0;
while ( pos < (length-1) )
{
sum += *(pkt+pos++);
}
sum = 0x0 - sum;
// return 0 or 1 based on the checksum test
return (sum == *(pkt+pos)) ? 1 : 0;
}

void calculateChecksum( uint8_t *pkt, uint32_t const length )
{
uint32_t pos = 0;
uint8_t sum = 0;
while ( pos < (length-1) )
{
sum += *(pkt+pos++);
}
// put the checksum into the data stream
*(pkt+pos) = 0x0 - sum;

return;
}

80 changes: 80 additions & 0 deletions src/checksum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @file checksum.h
* @brief Utility Function - Data integrity helpers
* @author sam grove
* @version 1.0
*
* Copyright (c) 2013
*
* 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.
*/

#ifndef CHECKSUM_H
#define CHECKSUM_H

#include <stdint.h>

/** Helpers for working data streams
*
* Example:
* @code
* #include "mbed.h"
* #include "checksum.h"
*
* DigitalOut myled(LED1);
*
* template <int T>
* struct data{
* uint8_t buf[T];
* uint8_t checksum;
* };
* data<12> all_ones = {{1,1,1,1,1,1,1,1,1,1,1,1}};
*
* int main()
* {
* calculateChecksum( all_ones.buf, sizeof(all_ones) );
*
* for(int i=0; i<sizeof(all_ones); i++)
* {
* printf("%02d: %d\n", i, *(all_ones.buf+i));
* }
*
* printf("checksum test: %s\n", (result)?"passed":"failed");
*
* while(1)
* {
* myled = 1;
* wait(0.2);
* myled = 0;
* wait(0.2);
* }
* }
* @endcode
*/

/** Calculate the checksum of a data stream
* Assumes the checksum is in the last position, 8-bits and 0 - the sum of data
* @param pkt - A pointer to the data
* @param length - The amount of data that the checksum calculates
* @returns true if the checksum is correct and false otherwise
*/
bool validateChecksum( uint8_t const *pkt, uint32_t const length );

/** Calculate and store the checksum into the last position of a data stream
*
* @param pkt - A pointer to the data
* @param length - The amount of data that the checksum calculates
*/
void calculateChecksum( uint8_t *pkt, uint32_t const length );

#endif
6 changes: 0 additions & 6 deletions src/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
"email": "narosenberg@wpi.edu"
}
],
"dependencies":
{
"name": "OneWire",
"authors": "Paul Stoffregen",
"frameworks": "arduino"
},
"version": "0.0.1",
"frameworks": "mbed",
"platforms": "ststm32"
Expand Down
31 changes: 0 additions & 31 deletions src/library0.json

This file was deleted.

14 changes: 0 additions & 14 deletions src/platformio.ini

This file was deleted.

14 changes: 0 additions & 14 deletions src/platformio0.ini

This file was deleted.

0 comments on commit 81bd764

Please sign in to comment.