Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/support/drivers/motor.lua
blob: c1a86d6ae6c56bd261d3958c9befa6b19c6a9bbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
local device = _G
local SET_VEL_ADL = 0x00 -- código de op para mover el motor hacia adelante
local SET_VEL_ATR = 0x01 -- código de op para mover el motor hacia atrás


api={}
api.setveladl = {}
api.setveladl.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
api.setveladl.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
api.setveladl.call = function (id, vel)
	local msg = string.char(SET_VEL_ADL,id, math.floor(vel / 256),vel % 256)
	device:send(msg)
	local ret = device:read(1)
	local raw_val = string.byte(ret or " ", 1) 
	return raw_val	 
end

api.setvelatr = {}
api.setvelatr.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
api.setvelatr.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
api.setvelatr.call = function (id, vel)
	local msg = string.char(SET_VEL_ATR,id, math.floor(vel / 256),vel % 256)
	device:send(msg)
	local ret = device:read(1)
	local raw_val = string.byte(ret or " ", 1) 	
	return raw_val	 
end


api.setvelatr2 = {}
api.setvelatr2.parameters = {[1]={rname="id", rtype="int"}, [2]={rname="vel", rtype="int"}} --primer parametro id motor, segundo velocidad
api.setvelatr2.returns = {[1]={rname="dato", rtype="int"}} --codigo de operación
api.setvelatr2.call = function (vel)
	local msg = string.char(SET_VEL_ATR,0, math.floor(vel / 256),vel % 256)
	device:send(msg)
	local msg = string.char(SET_VEL_ATR,1, math.floor(vel / 256),vel % 256)
	device:send(msg)
	local ret = device:read(1)
	local ret = device:read(1)
	local raw_val = string.byte(ret or " ", 1) 	
	return raw_val	 
end