Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
robotis_tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
humanoides
robotis_tools
Commits
c69d22fc
Commit
c69d22fc
authored
11 years ago
by
Patrick John Grosch Obregon
Browse files
Options
Downloads
Patches
Plain Diff
rx28 firmware interrupt ctrl cycle and read potenciometer work
parent
a8724b88
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
servo_firmware/rx28/Makefile
+2
-2
2 additions, 2 deletions
servo_firmware/rx28/Makefile
servo_firmware/rx28/src/main.c
+40
-51
40 additions, 51 deletions
servo_firmware/rx28/src/main.c
with
42 additions
and
53 deletions
servo_firmware/rx28/Makefile
+
2
−
2
View file @
c69d22fc
...
@@ -3,8 +3,8 @@ PROJECT=rx28_fw
...
@@ -3,8 +3,8 @@ PROJECT=rx28_fw
# afegir tots els fitxers que s'han de compilar aquí
# afegir tots els fitxers que s'han de compilar aquí
########################################################
########################################################
#SOURCES=src/main.c src/TXRX_Dynamixel.c src/CTRL_Dynamixel.c src/MEM_Dynamixel.c src/CFG_HW_Dynamixel.c
#SOURCES=src/main.c src/TXRX_Dynamixel.c src/CTRL_Dynamixel.c src/MEM_Dynamixel.c src/CFG_HW_Dynamixel.c
#
SOURCES=src/main.c src/CTRL_Dynamixel.c src/MEM_Dynamixel.c src/CFG_HW_Dynamixel.c
SOURCES
=
src/main.c src/CTRL_Dynamixel.c src/MEM_Dynamixel.c src/CFG_HW_Dynamixel.c
SOURCES
=
src/main.c src/CFG_HW_Dynamixel.c
#
SOURCES=src/main.c src/CFG_HW_Dynamixel.c
OBJS
=
$(
SOURCES:.c
=
.o
)
OBJS
=
$(
SOURCES:.c
=
.o
)
SRC_DIR
=
./src/
SRC_DIR
=
./src/
INCLUDE_DIR
=
./include/
INCLUDE_DIR
=
./include/
...
...
This diff is collapsed.
Click to expand it.
servo_firmware/rx28/src/main.c
+
40
−
51
View file @
c69d22fc
#include
<avr/io.h>
#include
<avr/io.h>
#include
<util/delay.h>
#include
<util/delay.h>
//
#include <avr/interrupt.h>
#include
<avr/interrupt.h>
//#include <avr/eeprom.h>
//#include <avr/eeprom.h>
#include
"CFG_HW_Dynamixel.h"
#include
"CFG_HW_Dynamixel.h"
//#include "TXRX_Dynamixel.h"
//#include "TXRX_Dynamixel.h"
//
#include "CTRL_Dynamixel.h"
#include
"CTRL_Dynamixel.h"
//
#include "MEM_Dynamixel.h"
#include
"MEM_Dynamixel.h"
//*************CTRL = INTERRUPT FUNCTION *********************************
//*************CTRL = INTERRUPT FUNCTION *********************************
uint16_t
count
=
0
;
uint16_t
count
=
0
;
uint16_t
count2
=
0
;
uint16_t
count2
=
0
;
/*ISR( TIMER0_OVF_vect) {
int16_t TorqueEnable;
sei();
ISR
(
TIMER0_OVF_vect
)
{
TorqueEnable = Read_byte_Dynamixel_RAM(Torque_Enable);
int16_t
TorqueEnable
;
if (TorqueEnable == 1) {
//if (1){
sei
();
// enable all interrupts
//cli(); // disable all interrupts just to make sure
//cli(); // disable all interrupts just to make sure
//TIMSK &= ~( 1 << TOIE0); // disable timer0
TorqueEnable
=
Read_byte_Dynamixel_RAM
(
Torque_Enable
);
count++;
if
(
TorqueEnable
==
1
)
{
if (count == 2) {
//if (0) {
// 1.3s passed
//ENABLE_MOTOR;
// LedTONGGLE();
DISABLE_MOTOR
;
Control_Cycle();
count
++
;
HW_Security();
count2
=
Read_Sensor
(
CTRL_Encoder_Port
);
Write_Actuator();
//if (count == 1) {
count = 0;
if
(
count
>
count2
)
{
}
LedTOGGLE
;
//TIMSK |= ( 1 << TOIE0); // enable timer0
//Control_Cycle();
//sei(); // enable all interrupts
//HW_Security();
} else {
//Write_Actuator();
OCR1A = CTRL_ZERO; //PB1 => set PWM for X% duty cycle
count
=
0
;
OCR1B = CTRL_ZERO; //PB2 => set PWM for Y% duty cycle
}
}
if
(
count
==
1023
)
{
}*/
count
=
0
;
}
}
else
{
DISABLE_MOTOR
;
SET_CCW_PWM_MOTOR
(
0
);
//PB1 => set PWM for X% duty cycle max 0x3ff o 1023 // funciona
SET_CW_PWM_MOTOR
(
0
);
//PB2 => set PWM for Y% duty cycle max 0x3ff o 1023 // funciona
//LedTOGGLE;
}
}
//**************** M A I N *********************************
//**************** M A I N *********************************
int16_t
main
(
void
)
{
int16_t
main
(
void
)
{
/*unsigned char data[128], id, length, instruction, answer[2], status,
unsigned
char
data
[
128
],
id
,
length
,
instruction
,
answer
[
2
],
status
,
en_vector, i, j;*/
en_vector
,
i
,
j
;
uint16_t
ii
,
jj
;
//double pwm;
// list of read only registers - to exclude from write
// list of read only registers - to exclude from write
/*unsigned char read_only_vector[30] = { 0, 1, 2, 36, 37, 38, 39, 40, 41, 42,
/*unsigned char read_only_vector[30] = { 0, 1, 2, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 67, 68, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 83,
43, 44, 45, 46, 67, 68, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 83,
...
@@ -59,31 +63,16 @@ int16_t main(void) {
...
@@ -59,31 +63,16 @@ int16_t main(void) {
// get value of Motor ID
// get value of Motor ID
rs485_address = eepromVAR[ID];*/
rs485_address = eepromVAR[ID];*/
// configure AVR chip i/o
// configure AVR chip i/o
Config_Hardware
();
Config_Hardware
();
/*// asign actual position to goal position and asume zero motor turns
// asign actual position to goal position and asume zero motor turns
Ini_Position();
Ini_Position
();
// initialize the RS485 interface
// initialize the RS485 interface
/*init_RS485();*/
init_RS485();*/
// end of inicialization
// end of inicialization
LedOFF
;
LedOFF
;
ENABLE_MOTOR
;
//DISABLE_MOTOR;
ii
=
900
;
jj
=
0
;
OCR1A
=
0
;
while
(
1
)
{
while
(
1
)
{
//LedTOGGLE; // funciona
//LedON; // funciona
//LedOFF; // funciona
_delay_ms
(
200
);
// funciona
ii
=
ii
+
10
;
SET_CCW_PWM_MOTOR
(
ii
);
// max 0x3ff o 1023 // funciona
//SET_CW_PWM_MOTOR(i); // max 0x3ff o 1023 // funciona
if
(
ii
>
1020
)
{
ii
=
100
;}
LedTOGGLE
;
// funciona
/*status = RxRS485Packet(&id, &instruction, &length, data);
/*status = RxRS485Packet(&id, &instruction, &length, data);
if (status == CHECK_ERROR) {
if (status == CHECK_ERROR) {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment