Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions MCTEST/DE0-nano-HD/.qsys_edit/filters.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<filters version="12.1sp1" />
20 changes: 20 additions & 0 deletions MCTEST/DE0-nano-HD/.qsys_edit/preferences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<preferences>
<debug showDebugMenu="0" />
<systemtable>
<columns>
<connections preferredWidth="127" />
<irq preferredWidth="34" />
</columns>
</systemtable>
<clocktable>
<columns>
<clockname preferredWidth="243" />
<clocksource preferredWidth="242" />
<frequency preferredWidth="225" />
</columns>
</clocktable>
<library
expandedCategories="Project,Library/University Program,Library/Memories and Memory Controllers,Library/University Program/Communications,Library" />
<window width="1163" height="860" x="277" y="0" />
</preferences>
383 changes: 383 additions & 0 deletions MCTEST/DE0-nano-HD/DE0.qsf

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions MCTEST/DE0-nano-HD/PLLJ_PLLSPE_INFO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PLL_Name pll_sys:inst_pll_sys|altpll:altpll_component|pll_sys_altpll:auto_generated|pll1
PLLJITTER 35
PLLSPEmax 84
PLLSPEmin -53

1,986 changes: 1,986 additions & 0 deletions MCTEST/DE0-nano-HD/Software/.metadata/.log

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<item value="org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem" key="org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage.selection"/>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*** SESSION Mar 06, 2014 10:00:43.86 -------------------------------------------
*** SESSION Mar 06, 2014 11:47:32.49 -------------------------------------------
*** SESSION Mar 10, 2014 16:30:59.48 -------------------------------------------
*** SESSION Mar 14, 2014 08:58:25.89 -------------------------------------------
*** SESSION Mar 14, 2014 14:14:22.06 -------------------------------------------
*** SESSION Mar 14, 2014 15:20:52.72 -------------------------------------------
*** SESSION Mar 14, 2014 15:59:07.38 -------------------------------------------
*** SESSION Mar 14, 2014 16:52:23.75 -------------------------------------------
*** SESSION Mar 14, 2014 17:00:13.53 -------------------------------------------
*** SESSION Mar 14, 2014 17:01:44.06 -------------------------------------------
*** SESSION Mar 19, 2014 11:41:31.61 -------------------------------------------
*** SESSION Mar 19, 2014 11:43:44.43 -------------------------------------------
*** SESSION Mar 20, 2014 12:42:31.63 -------------------------------------------
*** SESSION Mar 20, 2014 16:00:43.08 -------------------------------------------
*** SESSION Mar 20, 2014 16:01:05.21 -------------------------------------------
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

**** Build of configuration Nios II for project MCTest ****

make all
Info: Building ../MCTest_bsp/
make --no-print-directory -C ../MCTest_bsp/
[BSP build complete]
[MCTest build complete]

**** Build Finished ****
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

**** Build of configuration Nios II for project MCTest_bsp ****

make all
[BSP build complete]

**** Build Finished ****
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="completion_proposal_size">
</section>
<section name="PDOMSearchPage">
</section>
<section name="RenameInformationPopup">
</section>
<section name="org.eclipse.cdt.ui.text.hover.CMacroExpansionExploration.internal">
<item value="549" key="size.width"/>
<item value="180" key="size.height"/>
</section>
<section name="CRenameRefactoringInputPage">
</section>
<section name="org.eclipse.cdt.ui.text.hover.CMacroExpansionExploration">
</section>
</section>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* MotorHandler.h
*
* Created on: 2014-03-03
* Author: Amshu Gongal
*/

#ifndef MOTORHANDLER_H_
#define MOTORHANDLER_H_

#include "altera_up_avalon_rs232.h"
#include "altera_up_avalon_rs232_regs.h"
#include <stdio.h>
using namespace std;
#include <string>
#include "Status.h"

//Commands from network handler
#define MOTOR_LEFT "left"
#define MOTOR_RIGHT "right"
#define MOTOR_FORWARD "forward"
#define MOTOR_BACKWARD "backward"


// Motor messages are LSB first
#define MOTOR_START_BYTE 0x80
#define MOTOR_DEVICE_TYPE 0x00
#define MOTOR_LEFT_CHAR 0x02 // motor 1 backward
#define MOTOR_RIGHT_CHAR 0x03 // motor 2 backward
#define MOTOR_LEFT_FORWARD 0x05 // motor 1 forward
#define MOTOR_RIGHT_FORWARD 0x07 // motor 2 forward
#define MOTOR_CONST_SPEED 0x5F
#define MOTOR_STOP_SPEED 0x00
#define MOTOR_CHANGE_CONFIGURATION 0X02

class MotorHandler {
public:
MotorHandler();
virtual ~MotorHandler();

/*
* Initializes this handler.
* @return OK if the handler was initialized without error
*/
Status init();
void reset();
void configure();
void motorCommand(string motor, string motorDirection, string speed);

private:
/* The device used to send serial commands to the motor controller. */
alt_up_rs232_dev *motor_dev;

char interpretMotor(string motor);
char interpretDirection(string direction, int motor);

/*
* Moves in the given direction at constant speed.
* @param direction - the motor and direction to move in, e.g. MOTOR_MOTOR1_FORWARD
* @param speed speed of the motor
* @param description - the string description of the movement, for debugging
*/
void move(char direction, char speed, char *description);

/*
* Sends a byte-length message to the motor controller.
* @param message - the message to send
* @param description - the string description of the message, for debugging
*/
void send(char message, char *description);
};

#endif /* MOTORHANDLER_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*************************************************************************
* ARCap
* Amshu Gongal, Kenan Kigunda
* February 18, 2014
**************************************************************************
* Description: *
* Prototype testing for infrared and mc.
**************************************************************************/

#include <stdio.h>
#include "includes.h"
#include "altera_avalon_pio_regs.h"
#include "altera_avalon_uart_regs.h"
#include "sys/alt_irq.h"
#include "alt_types.h"
#include "altera_up_avalon_rs232.h"
#include "altera_up_avalon_rs232_regs.h"

#include "MotorHandler.h"
#include "Status.h"

/* Task stacks */
#define TASK_STACKSIZE 2048
OS_STK ir_task_stk[TASK_STACKSIZE];
OS_STK mc_task_stk[TASK_STACKSIZE];
/* Task priorities */
#define IR_TASK_PRIORITY 2
#define MC_TASK_PRIORITY 1


#define SW_READ 1
#define SW_WRITE 2
#define WRITE_FIFO_EMPTY 0x80
#define READ_FIFO_EMPTY 0x0
OS_EVENT *SWQ;
OS_EVENT *RS232Q;
INT8U err;


/* Error status */
#define OK 0

/* Message queues */
#define WAIT_FOREVER 0

// ==== INFRARED ====

/* Infrared message queue */
#define IR_MAX_MESSAGES 4
int ir_messages[IR_MAX_MESSAGES];
OS_EVENT *ir_queue;

/* Infrared messages */
// Together these avoid passing 0 to the queue (which is not allowed since queue messages cannot be null)
// and invert pushbutton input (since the pushbutton returns 0 when it is pushed down).
#define IR_QUEUE_SEND_BASE 1 // Use: IR_QUEUE_SEND_BASE + IORD
#define IR_QUEUE_RECEIVE_BASE 2 // Use: IR_QUEUE_RECEIVE_BASE - OSQPend


MotorHandler *motor= new MotorHandler();


// ==== mc

#define mc_GUARD_TIME 1

void mc_task(void *pdata)
{
printf("mc task\n");
printf("MotorHandler [init");
if (motor->init() == OK) {
printf("]\n\n");
motor->forward();
} else {
printf( ", error]\n");
}
while(1){
motor->forward();
OSTimeDlyHMSM(0, 0, 0, 100);
}
}



// ==== GENERAL

void queue_init() {
ir_queue = OSQCreate((void**)&ir_messages, IR_MAX_MESSAGES);
}

/* The main function creates the LCD task, registers the edge counter polling interrupt,
* and starts the OS. */
int main(void)
{
int status = OK;
// Initialize components.
queue_init();
IOWR_ALTERA_AVALON_PIO_DATA(PIO_MOTOR_RST_BASE, 0);
OSTimeDlyHMSM(0,0,0,100);
IOWR_ALTERA_AVALON_PIO_DATA(PIO_MOTOR_RST_BASE, 1);
// Create the mc task.
OSTaskCreateExt(mc_task,
NULL,
&mc_task_stk[TASK_STACKSIZE - 1],
MC_TASK_PRIORITY,
MC_TASK_PRIORITY,
mc_task_stk,
TASK_STACKSIZE,
NULL,
0);

if (status == OK) {
OSStart();
}

return 0;
}

/******************************************************************************
* *
* License Agreement *
* *
* Copyright (c) 2004 Altera Corporation, San Jose, California, USA. *
* All rights reserved. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *
* DEALINGS IN THE SOFTWARE. *
* *
* This agreement shall be governed in all respects by the laws of the State *
* of California and by the laws of the United States of America. *
* Altera does not recommend, suggest or require that this reference design *
* file be used in conjunction or combination with any other product. *
******************************************************************************/
Loading